Im creating a script to be removed after an onTouch function and Im not sure the right way to have it removed after its done. Can any one help me understand how the script needs to know that it was touched by a humanoid and it should remove its self?
local p = script.Parent
function onTouch(part)
local HumanoidIsFound = part.Parent:FindFirstChild("Humanoid")
local PlayerIsFound = game.Players:GetPlayerFromCharacter(part.Parent)
if HumanoidIsFound and PlayerIsFound then
wait(.5)
PlayerIsFound.PlayerGui.ScreenGuitycoon.TextButton.Visible = true
wait(1)
PlayerIsFound.PlayerGui.ScreenGuispawn.TextButton.Visible = false
end
end
p.Touched:connect(onTouch)

2 comments
this is giving me the error that hit is unknown globally
It shouldn't be doing that. I don't even use 'hit' in my script.