I currently have this code:
local UIS = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local tweenService = game:GetService("TweenService")
local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local humRootPart = char:FindFirstChild("HumanoidRootPart")
local mouse = plr:GetMouse()
local cam = workspace.CurrentCamera
local hookPoint = Vector3.new(0, 0, 0)
local isGrappleHookAttached = false
local isOnWall = false
local canAttach = true
local grapplingHookLength = 15000
local isIdle = true
function grappleHookRight()
UIS.InputBegan:Connect(function(input, gameProcessedEvent)
if UIS:IsKeyDown(Enum.KeyCode.E) then
local ray = Ray.new(humRootPart.Position, (mouse.Hit.p - humRootPart.Position).unit * 300)
local hit, position, normal = game.Workspace:FindPartOnRay(ray, char)
local distance = (position - humRootPart.Position).magnitude
grappleRight = Instance.new("RopeConstraint", game.Workspace)
at0 = Instance.new("Attachment", humRootPart)
at0.Position = Vector3.new(0, 0, 0)
at1 = Instance.new("Attachment", mouse.Target)
at1.WorldPosition = position
if hit then
grappleRight.Thickness = 0.05
grappleRight.Attachment0 = at0
grappleRight.Attachment1 = at1
grappleRight.Visible = true
grappleRight.Enabled = true
grappleRight.Color = BrickColor.new("Black")
grappleRight.Length = distance
runService.Heartbeat:Wait()
local bodyVelocity = Instance.new("BodyVelocity", humRootPart)
bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyVelocity.P = 2000
bodyVelocity.Velocity = position
UIS.InputEnded:Connect(function(input, gameProcessedEvent)
bodyVelocity:Destroy()
grappleRight:Destroy()
at0:Destroy()
at1:Destroy()
end)
end
end
end)
end
grappleHookRight()
Please Help.

1 comment
I suggest you tween the players HumanoidRootPart instead. It will be cleaner