How can I make this Touched function not do what it is told to do infinite times?
So I have this working script that is going to be able to manipulate the player's camera:
1 | function cloneLocalScript(playerWhoTouched) |
2 | local userCharacter = playerWhoTouched.Parent |
3 | local userPlayer = game.Players:GetPlayerFromCharacter(userCharacter) |
4 | script.LocalScript:clone().Parent = userPlayer.PlayerGui.cameraStuff |
7 | 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.