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
Your script was weird so i made another one for you, if it doesnt work comment the error
gui = guiposition function touched(obj) if obj.Parent:FindFirstChild("Humanoid") ~= then wsplayer = obj.Parent player = game.Players:FindFirstChild(wsplayer.Name) if player:FindFirstChild(gui.Name) ~= nil then clone = gui:Clone()clone.Parent = player.PlayerGui game:GetService("Debris"):AddItem(clone,2) end end end script.Parent.Touched:connect(touched)