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

Script Help! PLEASE HELP?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

This is what I have so far. It works fine but it gives you more then one GUI when you step on it. I need a add on so it checks to see if you already have a GUI and not give you one if you already do have one

function onTouch(hit)

local ptt = game.Players:playerFromCharacter(hit.Parent)
if ptt == nil then return end 
local wfp = script.Parent:findFirstChild("HandtoGui"):clone() 
if wfp == nil then return end 
wfp.Parent = ptt.PlayerGui
end

script.Parent.Touched:connect(onTouch)

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
8 years ago

You could set a line that returns false if it finds that GUI in their PlayerGui. So..

function onTouch(hit)
    local ptt = game.Players:GetPlayerFromCharacter(hit.Parent)
    if ptt == nil then return end
    local wfp = script.Parent:findFirstChild('HandtoGui"):clone()
    if ptt.PlayerGui:findFirstChild("HandtoGui") then return end
    wfp.Parent = ptt.PlayerGui
end

script.Parent.Touched:connect(onTouch)
0
Thank you Shawny CorruptBullet 5 — 8y
Ad

Answer this question