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 8 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.

01script.Parent.Touched:connect(function(toucher)
02    local plr = game:GetService("Players"):GetPlayerFromCharacter(toucher.Parent) or game:GetService("Players"):GetPlayerFromCharacter(toucher.Parent.Parent)
03    if plr then
04        local help = game:GetService("ReplicatedStorage"):WaitForChild("Intro")
05        help:Clone(1).Parent = plr.PlayerGui
06else
07    script.Parent.Touched:connect(function(awsomeness)
08        local plr = game:GetService("Players"):GetPlayerFromCharacter(awsomeness.Parent) or game("Players"):GetPlayerFromCharacter(awsomeness.Parent.Parent)
09        if plr then
10            local off = plr.PlayerGui:WaitForChild("Intro")
11            off:Destroy()
12        end
13    end)
14    end
15end)
0
You want the part or the gui to dissapear? RubenKan 3615 — 8y
0
gui supercoolboy8804 114 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

I would do it another way.

01local debounce = false --add this and call it whatever you want
02--then add in your script a check
03if plr and not debounce then
04--lines to Clone that gui
05debounce = true
06--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)
07 
08--remove script.Parent.Touched:connect(function(awsomeness) as you already did that in the beginning so this is not needed
09--remove 1 end) and 1 end from the end
10--after that replace else with elseif and just do like I'll do down here
11elseif plr and debounce then
12local off = plr.PlayerGui:WaitForChild('Intro')
13off:Destroy() --btw if this won't work then replace Destroy() with Remove()
14debounce = false

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

Ad

Answer this question