I have a part when you touch it, a gui pops up. I want that gui to go away in 2 seconds ONCE it pops up. I have tryed the script below but the gui does not pop up.
wait(2)
script.Parent:remove()
The script below is the other script to make it appear.
wait(1)
local near = false
local debounce = true
if near == true then
while wait(0.1) do
for i,v in pairs(game.Players:GetChildren()) do
if v.Character.Torso ~= nil then
if(v.Character.Torso.Position - script.Parent.Position).magnitude < (script.Parent.Size.X /1) + 10 then
if v.PlayerGui:findFirstChild("ExampleGui") ~= nil then return end
script.ExampleGui:clone().Parent = v.PlayerGui
end
end
end
end
elseif near == false then
if debounce == true then
debounce = false
script.Parent.Touched:connect(function(hit)
local human = hit.Parent:findFirstChild("Humanoid")
if (human == nil) then return end
local player = game.Players:findFirstChild(hit.Parent.Name)
if (player == nil) then return end
if player.PlayerGui:findFirstChild("ExampleGui") ~= nil then return end
script.ExampleGui:clone().Parent = player.PlayerGui
end)
debounce = true
end
end

1 comment
could we see that script? We need to see that it may not be this part of the script