Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Gui help?

Asked by 9 years ago

This gives the player MANY guis when it's touched.

01local pad = script.Parent
02local gui = game.ServerStorage.EditChar1
03local function steppedOn(part)
04    local character = part.Parent  
05    local player = game.Players:GetPlayerFromCharacter(character)
06        if player then
07        local guiCopy = game.ServerStorage.EditChar1:Clone()
08        guiCopy.Parent = player.PlayerGui      
09 
10    end
11    end
12pad.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.

0
i would check to see if the player has it before adding it ProfessorSev 220 — 9y
0
Please update the code to the one you were using with the answer below. AmericanStripes 610 — 9y

1 answer

Log in to vote
2
Answered by 9 years ago

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.

you need to check to see if the player has it before adding it

01local pad = script.Parent
02local gui = game.ServerStorage.EditChar1
03local function steppedOn(part)
04         local character = part.Parent  
05     local player = game.Players:GetPlayerFromCharacter(character)
06         if player then
07        if  not (player.PlayerGui:FindFirstChild("EditChar1")) then
08                local guiCopy = game.ServerStorage.EditChar1:Clone()
09                guiCopy.Parent = player.PlayerGui      
10        end
11     end
12end
13 
14 
15pad.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

0
So the gui's called "EditChar1". How would I incorporate this into the above script. the perimeters confuse me, I dont understand them TheScriptingAccount 90 — 9y
0
Yeah, I just added this to the script but it's adding it several times still. Not sure why. TheScriptingAccount 90 — 9y
1
sorry for the messed up tabbing but that would be the code that you could use ProfessorSev 220 — 9y
0
Yeah it worked thanks so much. TheScriptingAccount 90 — 9y
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. AmericanStripes 610 — 9y
Ad

Answer this question