Hello all,
I have written a script (for a lift) where a gui is shown once the player touches the part, with teleport buttons on (so you can travel to each floor). Once you click any of the buttons, it is set to make the frame inside the GUI invisible so you can walk around. However, once its gone invisible, it does not come back if any of the blocks are touched.
This is my script inside the parts to bring up the GUI
local GUI = game.ServerStorage.LiftGUI
script.Parent.Touched:Connect(function(hit)
if hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then
local plr = game.Players[hit.Parent.Name]
if plr:FindFirstChild("PlayerGui") and not plr.PlayerGui:FindFirstChild(GUI.Name) then
GUI:Clone().Parent = plr.PlayerGui
end
end
end)
This is my teleport script inside all of the buttons in the GUI (which does the teleport and also closes the GUI)
player = game.Players.LocalPlayer
button = script.Parent
function onClick()
script.Parent.Parent.Visible = false
local LowerTorso = player.Character.LowerTorso
LowerTorso.CFrame = game.Workspace.lobbytp.CFrame
end
button.MouseButton1Click:connect(onClick)
No, that does not work. Surely that is still executing the same thing I said, except that it would bring the gui back if the button was pressed again. However the buttons are inside the frame that disappears when you teleport.
–the code you write only clone the gui when is touched and when is touched again if its cloned already it won’t do anything, you need to make it visible again when you touch it
mmmm try to add this below that
–when you touch the part you want to make visible that gui try to adapt this
if plr:FindFirstChild(“PlayerGui”) and plr.PlayerGui:FindFirstChild(GUI.Name).Visible == false then
plr.PlayerGui:FindFirstChild(GUI.Name).Visible = true
end
if hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then
local plr = game.Players[hit.Parent.Name]
if plr:FindFirstChild(“PlayerGui”) and not plr.PlayerGui:FindFirstChild(GUI.Name) then
GUI:Clone().Parent = plr.PlayerGui
1-Dont make frame invisible, make THE GUI enabled propperty to false
2-You can ADD the GUI to player starter gui and make it disabled already
3-You enable GUI when part is touched and disable when you press a button or leave certain distance of the part you touched
4-The pseudocode is the logic of how you later proceed to code your stuff.
5-Try to rewrite your code using the pseudocodes and converting it to lua code.