its local script
local Player = game:GetService("Players").LocalPlayer
local rp = game:GetService("ReplicatedStorage")
local Teleport = rp:WaitForChild("Stand1Remotes"):WaitForChild("Teleport")
local debounce = false
local cooldown = 5
local UIS = game:GetService("UserInputService")
local debounce = false
local Player = game:GetService'Players'.LocalPlayer
local UIS = game:GetService('UserInputService')
local Mouse = Player:GetMouse()
local Player = game:GetService'Players'.LocalPlayer
local Mouse = Player:GetMouse()
local Cooldown = false
UIS.InputBegan:Connect(function(key, IsTyping)
if IsTyping or Cooldown then return end
if key.KeyCode == Enum.KeyCode.H then
Cooldown = true
local Character = Player.Character or Player.CharacterAdded:Wait()
local Root = Character:WaitForChild('HumanoidRootPart')
Root.CFrame = Mouse.Hit
Teleport:FireServer()
wait(3)
Cooldown = false
end
end)

3 comments
Just get the magnitude of the distance between the rootpart and the mouse.hit and see if it's beyond a certain value (i.e 50 studs); then end the function if it is.
By magnitude of the distance I mean (Mouse.Hit - RootPart.CFrame).Magnitude > 50.
im still like know 3.5/10 in scripting so can you do the script for a fellow learner