I have this script, its meant to detect if the localplayer touches it and does something if they do.
local player = game.Players.LocalPlayer script.Parent.Touched:connect(function (hit) if hit.Parent == player then player.StarterGui.examplegui:Destroy() end end)
however it does nothing, please help as in a rush to complete the script!
The player is just a player object, not the item touching it. The item that is touching it is the player's character
. You need to reference the character in the script, otherwise it will never work.
local player = game.Players.LocalPlayer repeat wait() until player.Character script.Parent.Touched:connect(function (hit) if hit.Parent == player.Character then player.PlayerGui.examplegui:Destroy() --Player does not have a StarterGui, but it's own PlayerGui. end end)