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

A script that removes a gui after a set time

Asked by
Exsius 162
10 years ago

I'm trying to find a script that when you touch a block a gui pops up for about (5)secs and then destroys the gui!

Thanks,

Exsius,

I tried doing

p = script.Parent
gui = p.Gui

p.Touched:connect(function(hit)
plr = game.Players:findFirstChild(hit.Parent.Name)

gui:clone().Parent = plr.PlayerGui

wait(5)

gui:Remove()
end)

but it wouldn't destroy itself and disappear...

1 answer

Log in to vote
1
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago

Put the script inside of a brick, put your GUI inside of the script.

local gui = script["GUINAME"]
local db = true
script.Parent.Touched:connect(function(hit)
    if hit.Parent:findFirstChild("Humanoid") and db then
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        if plr and not plr.PlayerGui:findFirstChild(gui.Name) then
            db = false
            local cl = gui:Clone()
            cl.Parent = plr.PlayerGui
            game.Debris:AddItem(cl, 5)
            wait()
            db = true
        end
    end
end)

If you have trouble setting it up.

0
Thank you alot! I truly appreciate your help! Thanks for taking your time to help me! Exsius 162 — 10y
0
np Azarth 3141 — 10y
Ad

Answer this question