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

How can i make it where the part will disappear when i touch it?

Asked by 7 years ago

Every time i touch the brick, the gui appears, but when i touch it again, it doesn't disappear, but clones it self again in the player gui. How can i make it where if i touch it it disappears instead of cloning itself even more? This script is in a regular script.

script.Parent.Touched:connect(function(toucher)
    local plr = game:GetService("Players"):GetPlayerFromCharacter(toucher.Parent) or game:GetService("Players"):GetPlayerFromCharacter(toucher.Parent.Parent)
    if plr then
        local help = game:GetService("ReplicatedStorage"):WaitForChild("Intro")
        help:Clone(1).Parent = plr.PlayerGui
else
    script.Parent.Touched:connect(function(awsomeness)
        local plr = game:GetService("Players"):GetPlayerFromCharacter(awsomeness.Parent) or game("Players"):GetPlayerFromCharacter(awsomeness.Parent.Parent)
        if plr then
            local off = plr.PlayerGui:WaitForChild("Intro")
            off:Destroy()
        end
    end)
    end
end)
0
You want the part or the gui to dissapear? RubenKan 3615 — 7y
0
gui supercoolboy8804 114 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

I would do it another way.

local debounce = false --add this and call it whatever you want
--then add in your script a check
if plr and not debounce then
--lines to Clone that gui
debounce = true
--also add a wait() after this and write in brackets down the amount of seconds you need (the length of your Intro in secs, if it is a Intro and not a help gui)

--remove script.Parent.Touched:connect(function(awsomeness) as you already did that in the beginning so this is not needed
--remove 1 end) and 1 end from the end
--after that replace else with elseif and just do like I'll do down here
elseif plr and debounce then
local off = plr.PlayerGui:WaitForChild('Intro')
off:Destroy() --btw if this won't work then replace Destroy() with Remove()
debounce = false

Or do you want to write the whole script down for you?

Ad

Answer this question