So I wanted to make when the player clicks GUI button and value is 1 then teleport to the position, But it isn't working. This is the script.

local player=game.Players.LocalPlayer

function teleportPlayer(position)
    player.Character:MoveTo(position)
end
if game.ReplicatedStorage.RespawnHelper.Value == 1 then
	script.Parent.Parent.Button.MouseButton1Down:connect(function()
    teleportPlayer(Vector3.new(-16.885, 81.279, 111.005))

end)

end

1 comment

0

Put the if statement inside the button listener and put the teleport player stuff inside the if statement.