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

Gui help?

Asked by 8 years ago

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.

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

1 answer

Log in to vote
2
Answered by 8 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


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

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 — 8y
0
Yeah, I just added this to the script but it's adding it several times still. Not sure why. TheScriptingAccount 90 — 8y
1
sorry for the messed up tabbing but that would be the code that you could use ProfessorSev 220 — 8y
0
Yeah it worked thanks so much. TheScriptingAccount 90 — 8y
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 — 8y
Ad

Answer this question