Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Gui help?

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.

2 comments

0

i would check to see if the player has it before adding it

0

Please update the code to the one you were using with the answer below.

1 answer

✓ Accepted answer

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

5 comments

0

So the gui's called "EditChar1". How would I incorporate this into the above script. the perimeters confuse me, I dont understand them

0

Yeah, I just added this to the script but it's adding it several times still. Not sure why.

1

sorry for the messed up tabbing but that would be the code that you could use

0

Yeah it worked thanks so much.

0

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.