Hi, so I want to make a part that when you touch it it clones a localscript into that player's playergui. Problem is, when 2 players touch it at the same time, the script attempts to clone the localscript into BOTH players' playergui, which interferes with the script. Duplicate LocalScripts in one PlayerGui cause the script to break. How do I make it so the script only puts the localscript into players' playerguis when they haven't touched it previously?
local Players = game:GetService("Players")
local cutscene=script.LocalScript
local cutsceneinsert=cutscene:Clone()
local part = script.Parent
local function onTouched(part)
local player = Players:GetPlayerFromCharacter(part.Parent)
if not player then return end
cutsceneinsert.Parent=player.PlayerGui
part.Parent:FindFirstChild("Humanoid").JumpPower = 0
part.Parent:FindFirstChild("Humanoid").WalkSpeed = 0
wait(13)
part.Parent:FindFirstChild("Humanoid").JumpPower = 50
part.Parent:FindFirstChild("Humanoid").WalkSpeed = 20
end
part.Touched:Connect(onTouched)

1 comment
Add a debounce in the script so that it waits after the first person touches it.