Im trying to do a button GUI that teleports you to mouse's CFrame, however i don't know how to turn off when press the GUI again. Here's the script:
local botao = script.Parent
local player = game.Players.LocalPlayer
local nome = player.Name
ligado = false
botao.MouseButton1Down:connect(function()
if ligado == false then
local mouse = player:GetMouse()
mouse.Button1Down:connect(function()
local loca = mouse.Hit.p
workspace[nome].HumanoidRootPart.CFrame = CFrame.new(loca)
ligado = true
end)
elseif ligado == true then
local mouse = player:GetMouse()
ligado = false
end
end)
How to do this turn off when i press the GUI again?

2 comments
What do you mean like turn off the script?
turn off the mouse teleports