A script for the script.got the teleporting down but may teleport too far

local remote = game.ReplicatedStorage:WaitForChild("telemote")


remote.OnServerEvent:Connect(function(plr,mousehit)


local char = plr.Character or plr.CharacterAdded:Wait()



local position = mousehit.p


char.HumanoidRootPart.CFrame = position ----I want it with in 20 studs though...…./

4 comments

0

Transform mousehit.p into a vector, subtract it from the player's position, and get the magnitude of the resulting vector. If the magnitude is > 20, then don't teleport.

0

How do I make it a vector?

0

mousehit.P would be a Vector3 instance

0

the position of the actual mouse cursor is a Vector2 instance