Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

A script that removes a gui after a set time

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

✓ Accepted answer

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.

2 comments

0

Thank you alot! I truly appreciate your help! Thanks for taking your time to help me!

0

np

This discussion is preserved as it was. New answers, comments, and votes are closed.