Okay, so let me explain what I wanted. And what the problem is, before I present the script. Okay so I made a gui with a text button. And it is supposed to take you from the lobby to the game, then after it does the text changes from "Game" to "Lobby", and when you click it again it is supposed to take you back to the lobby, then repeat this. The problem is that when you click it takes you to the game, then text changes to "Lobby" but when you click, it doesn't take you to the lobby part I am using the positions of the parts and idk if it is how I am doing it or not. And I am wondering how will I make it repeat? I've been working on it for a while, and I'd appreciate if anyone has a idea or clue how to fix this? Or make it better??
SCRIPT
local ingame = false
wait(.5)
game.Players.LocalPlayer.PlayerGui.ScreenGui.TextButton.Text = ("Game")
script.Parent.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.character.Torso.CFrame = CFrame.new(workspace.gameT.position)
if ingame == false then
wait(.1)
game.Players.LocalPlayer.PlayerGui.ScreenGui.TextButton.Text = ("Lobby")
script.Parent.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.character.Torso.CFrame = CFrame.new(workspace.lobbyT.Position)
wait(.1)
end)
end
end)
here is a gif of what happens too btw: https://gyazo.com/11489be121de4cff760bfb71b6a9d695

2 comments
Your scripting is very messy. I recommend using 1 MouseButton1Click event over using 2 with one wrapping around the other and also you didn't change the ingame boolean
Sorry, I'm not that well at scripting. And I didn't realize how messy it was with the boolean lol. Thank you for the recommendation