was experimenting that I want that when a player touch a part, The gui shows and it's shows again when a player touchs the part again. But the script that i have it's only close the gui and it's doesn't open anymore. "It's a teleportation Gui but i want that the gui shows repeatedly"
This is the script:
local Part = script.Parent local Debounce = false Part.Touched:Connect(function(hit) if Debounce == false then Debounce = true if hit.Parent:FindFirstChild("Humanoid") then local plr = game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui script.ScreenGui:Clone().Parent = plr -- replace "ScreenGui" with the name of your ScreenGui end wait(1) Debounce = false end end)
Close teleport gui script:
script.Parent.MouseButton1Click:Connect(function() script.Parent.Parent.Visible = false end)
Now, I am talking about the script that you wrote below because it's more important. The issue is that the script.Parent.Parent.Visible = false
refers that it will only do that action, try to use this script:
script.Parent.MouseButton1Click:Connect(function() if script.Parent.Parent.Visible == false then script.Parent.Parent.Visible = true else script.Parent.Parent.Visible = false end end)
Explanation:
When you press the button, if the ScreenGUI or whatever it is isn't visible, it becomes visible, else, it's going to make it invisible if it's open.
I hope it helps and solves your problem.
try this:
local Part = script.Parent local Debounce = false Part.Touched:Connect(function(hit) if Debounce == false then Debounce = true if hit.Parent:FindFirstChild("Humanoid") then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) -- make sure this IS a player thats touched us!.. if(plr ~= nil) then --// we have a player, Woot! local PlayerGui = plr.PlayerGui local Gui = PlayerGui:FindFirstChild(script.ScreenGui.Name) --// Check to see if this player has our gui already, if not then clone/give it!... if(Gui == nil) then Gui = script.ScreenGui:Clone() Gui.Parent = PlayerGui -- replace "ScreenGui" with the name of your ScreenGui end --// no matter what we show the gui! Gui.Visible = true end end wait(1) Debounce = false end end)
I've just added a few checks to make sure the script doesn't crash and burn if a non player touches your touch brick/part.
You don't need to change your Close teleport gui script
as the above script re-shows your Gui if it finds it in the player. If it doesn't find the Gui in the PlayerGui
it will clone it!.
Hope this helps! :)
**Because u parent the gui to the player not the player gui.
on line 9 replace the code with this.**
script.ScreenGui:Clone().Parent = plr.PlayerGui -- replace "ScreenGui" with the name of your ScreenGui
Hope this helps!