【问题标题】:Roblox - Argument 1 missing or nilRoblox - 参数 1 缺失或无
【发布时间】:2020-09-20 06:44:43
【问题描述】:

我正在尝试编写一个脚本,当你触摸一个字符的命中框时,会出现某个聊天,但输出窗口显示“Argument 1 missing or nil”。

代码:

local debounce = false

game.Workspace.RowanAsleep.RowanAsleepHitbox.Touched:Connect(function(hit)  

    if not debounce then
        debounce = true
        if game.Players:GetPlayerFromCharacter(hit.Parent)then
            game.ReplicatedStorage.RowanTalking.RowanSleeping:FireClient()
        end
        wait(2)
        debounce = false
    end
end)

【问题讨论】:

    标签: lua roblox


    【解决方案1】:

    在第 8 行,FireClient() 需要传递一个播放器实例。尝试使用 GetPlayerFromCharacter 的结果创建一个变量并将其传递给 FireClient。

    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then --GetPlayerFromCharacter will only return nil or a player instance
        game.ReplicatedStorage.RowanTalking.RowanSleeping:FireClient(player)
    end
    

    【讨论】:

    • 感谢您的帮助!
    猜你喜欢
    • 2018-07-14
    • 2020-12-17
    • 2017-10-22
    • 2015-06-01
    • 2019-05-10
    • 2019-09-28
    • 1970-01-01
    • 1970-01-01
    • 2014-04-26
    相关资源
    最近更新 更多