It's a remoteEvent (Because I have to change a gui)
What's wrong? I keep getting the error 'Unable to cast value to Object' Line 8
local deb = false function onTouch(part) if deb == false then deb = true local human = part.Parent:findFirstChild("Humanoid") if (human == nil) then return end script.Parent.RemoteEvent:FireClient(human.Parent.Name) wait(1) deb = false end end script.Parent.Touched:connect(onTouch)
You're using the RemoteEvent wrong. You cannot pass in a name in the FireClient method. Instead a player must be passed into the method. In this instance I'll use the GetPlayerFromCharacter method of game.Players to fulfill this.
local deb = false function onTouch(part) if deb == false then deb = true local human = part.Parent:findFirstChild("Humanoid") if human then local player = game.Players:GetPlayerFromCharacter(human.Parent) if player then script.Parent.RemoteEvent:FireClient(player) wait(1) deb = false else wait(1) deb = false end else deb = false end end end script.Parent.Touched:connect(onTouch)