This gives the player MANY guis when it's touched.
local pad = script.Parent local gui = game.ServerStorage.EditChar1 local function steppedOn(part) local character = part.Parent local player = game.Players:GetPlayerFromCharacter(character) if player then local guiCopy = game.ServerStorage.EditChar1:Clone() guiCopy.Parent = player.PlayerGui end end pad.Touched:connect(steppedOn)
How could I reduce this to 1 without adding a wait because if I add a wait it would just add more after the wait.
you need to check to see if the player has it before adding it
local pad = script.Parent local gui = game.ServerStorage.EditChar1 local function steppedOn(part) local character = part.Parent local player = game.Players:GetPlayerFromCharacter(character) if player then if not (player.PlayerGui:FindFirstChild("EditChar1")) then local guiCopy = game.ServerStorage.EditChar1:Clone() guiCopy.Parent = player.PlayerGui end end end pad.Touched:connect(steppedOn)
basically what i added to the code was everytime that someone steps on the part and tries to get the gui i checked to see if the player had the gui in their playerGui folder already. If the player didnt have it then we added it to them so it is only added once