Sound = script.Parent.Sound
Image = script.Parent.ScreenGui
Ready = true
function onTouch(t)
local a = t.Parent:FindFirstChild("Humanoid")
if a ~= nil and Ready == true then
Ready = false
local b = Image:Clone()
local player = game.Players:FindFirstChild(a.Parent.Name)
b.Parent = player.PlayerGui
script.Parent.Sound:Play()
wait(2)
b:remove()
wait(1)
Ready = true
end
end
script.Parent.Touched:connect(onTouch())
错误:工作区。部件。脚本:5:尝试用"Parent"索引nil-服务器-脚本:5
非常简单的问题
Sound = script.Parent.Sound
Image = script.Parent.ScreenGui
Ready = true
function onTouch(t)
local a = t.Parent:FindFirstChild("Humanoid")
if a ~= nil and Ready == true then
Ready = false
local b = Image:Clone()
local player = game.Players:FindFirstChild(a.Parent.Name)
b.Parent = player.PlayerGui
script.Parent.Sound:Play()
wait(2)
b:remove()
wait(1)
Ready = true
end
end
script.Parent.Touched:Connect(onTouch)
省略最后一行的大括号,因为您调用函数onTouch时没有参数,现在Connect调用它时带有部件参数,简单修复。https://developer.roblox.com/en-us/api-reference/event/BasePart/Touched
如果您需要更多帮助,请回复:(
--Harvey