Okay all I need to know is I want the player to teleport anywhere but it has to be less than a specific distance, lets say 50 studs how would I add that to my script? What would I use? script ----
p = game.Players.LocalPlayer c = p.Character mouse = p:GetMouse() k = false dist = 50 function Main() if k == false and p:WaitForChild("Data").doingMove.Value == false then k = true local pos = mouse.Hit.p p:WaitForChild("Data").doingMove.Value = true c.Torso.CFrame = CFrame.new(Vector3.new(pos.x, pos.y+3, pos.z)) wait(.5) p:WaitForChild("Data").doingMove.Value = false wait(2) k = false end end script.Parent.Activated:connect(Main)
So, there's this thing called Magnitude. In vectors (what roblox uses for position) it means length (If you want to study up on the math of magnitude, goto the wiki page: http://wiki.roblox.com/index.php?title=Magnitude ) Magnitude basically gets distance between two vectors in ROBLOX's case.
Here's a clip of code to help you get started:
local mag = (mouse.Hit.p - c.Torso.Position).magnitude if mag < 50 then teleport() end
Do NOT copy and paste, this is just an example using some of your variables.