Hi, so I tried to make a part that when you touch it it clones a script into the player's playergui. When two people touch the part,** I want the script to clone the localscript once into each player's playergui and never again.** How do I set up the script so that if one player steps on the part while another is standing on it (and already has the LocalScript) it will only clone into the most recent player's playergui without the need for a debounce pause?
local Players = game:GetService("Players") local cutscene=script.AnnouncementScript 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 end part.Touched:Connect(onTouched)
local Players = game:GetService("Players") local cutscene=script.AnnouncementScript local cutsceneinsert=cutscene:Clone() local part = script.Parent local function onTouched(part) local player = Players:GetPlayerFromCharacter(part.Parent) if not player or player.PlayerGui:FindFirstChild(cutsceneinsert.Name) 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 end part.Touched:Connect(onTouched)
My edit here is: 'if not player or player.PlayerGui:FindFirstChild(cutsceneinsert.Name) then return end'
I check if the user's PlayerGui contains the cutscene GUI and if so, it will return out of the function.