Does anyone know why this happens? Please try it in a new place. I don't know whats wrong. Whenever it reaches 60 it is supposed to teleport me back to my last location but the thing that happens is that my character goes through the floor and the camera goes up a lot.
local UserInputService = game:GetService("UserInputService") local CanSetPos = script.CanSetPo local player = game.Players.LocalPlayer local hum = player.Character.HumanoidRootPart local Positions = { } function TrackPos(key) if key.KeyCode == Enum.KeyCode.E then if table.getn(Positions) == 60 then hum.Position=Vector3.new(Positions[25],Positions[26],Positions[27]) else print("not 27, it is:"..table.getn(Positions)) end end end UserInputService.InputBegan:connect(TrackPos) -- getting positions while wait(0.2) do if table.getn(Positions) == 60 then local currentpos = player.Character.HumanoidRootPart.Position local x = currentpos.x local y = currentpos.y local z = currentpos.z table.remove(Positions,1) table.remove(Positions,2) table.remove(Positions,3) table.insert(Positions,x) table.insert(Positions,y+10) table.insert(Positions,z) else local currentpos = player.Character.HumanoidRootPart.Position local x = currentpos.x local y = currentpos.y local z = currentpos.z table.insert(Positions,x) table.insert(Positions,y) table.insert(Positions,z) end end
The CanSetPos is a boolvalue set to true that is located under the script.