So I have this working script that is going to be able to manipulate the player's camera:
function cloneLocalScript(playerWhoTouched) local userCharacter = playerWhoTouched.Parent local userPlayer = game.Players:GetPlayerFromCharacter(userCharacter) script.LocalScript:clone().Parent = userPlayer.PlayerGui.cameraStuff end script.Parent.Touched:connect(cloneLocalScript)
This is the script that will move the local script into the PlayerGui.
The problem is that if the player steps over it once, dozens of scripts will be cloned into the PlayerGui.
Is there a way to stop this from happening; a way to check if there is already one and not allow the player to keep taking?
Thanks in advanced.
Debounce and an if statement.
local touched = false function cloneLocalScript(playerWhoTouched) if not touched then touched = true local userCharacter = playerWhoTouched.Parent local userPlayer = game.Players:GetPlayerFromCharacter(userCharacter) if not userPlayer.PlayerGui.cameraStuff:findFirstChild('LocalScript') then script.LocalScript:clone().Parent = userPlayer.PlayerGui.cameraStuff end touched = false end end script.Parent.Touched:connect(cloneLocalScript)