I’m working on a zipline creating system using a tool that fires a projectile hook forward until it hits something and so far its worked fine. However, for some reason the hook offsets to the side upon contact yet I’m not sure why. I’m using bodyvelocity to propel it towards wherever the player has clicked (I know this has been replaced with alignposition but I find it easier to use). Any help would be greatly appreciated as I’m really not sure what I’ve done wrong here.
the local script
local GrappleGun = script.Parent
local CanUse = trueGrappleGun.Equipped:Connect(function(Mouse)
Mouse.TargetFilter = game.Workspace.Ammunition
Mouse.Button1Down:Connect(function()
if CanUse then
game.ReplicatedStorage.FireGrapple:FireServer(Mouse.Hit.Position, GrappleGun)
CanUse = false
wait(1)
CanUse = true
end
end)
end)
the server script
local RS = game:GetService(“RunService”)
local UIS = game:GetService(“UserInputService”)game.ReplicatedStorage.FireGrapple.OnServerEvent:Connect(function(Plr, MousePosition, GrappleGun)
if game.Workspace.Ammunition:FindFirstChild(Plr.Name…"'s_GrappleHook") then
game.Workspace.Ammunition:FindFirstChild(Plr.Name…"'s_GrappleHook"):Destroy()
end
local HasHit = false
local GrappleHook = game.ReplicatedStorage.GrappleHook:Clone()
GrappleHook.Parent = game.Workspace.Ammunition
GrappleHook.CFrame = CFrame.new(GrappleGun.Crossbow.GrappleHook.Position, MousePosition)
GrappleHook.Name = Plr.Name…"'s_GrappleHook"
local StartPart = Instance.new(“Part”)
StartPart.Parent = GrappleHook
StartPart.Position = GrappleGun.Crossbow.GrappleHook.Position
StartPart.Anchored = true
StartPart.CanCollide = false
StartPart.Transparency = 1
local Attachment0 = Instance.new(“Attachment”)
Attachment0.Parent = GrappleHook
local Attachment1 = Instance.new(“Attachment”)
Attachment1.Parent = StartPart
local Zipline = Instance.new(“Beam”)
Zipline.Parent = GrappleHook
Zipline.Attachment0 = Attachment0
Zipline.Attachment1 = Attachment1
Zipline.FaceCamera = true
Zipline.Width0 = 0.5
Zipline.Width1 = 0.5
Zipline.Color = ColorSequence.new(Color3.fromHSV(0,0,0))
Zipline.Transparency = NumberSequence.new({
NumberSequenceKeypoint.new(0, 0),
NumberSequenceKeypoint.new(0.5, 0),
NumberSequenceKeypoint.new(1, 0)
}
)local BodyVelocity = Instance.new(“BodyVelocity”, GrappleHook)
BodyVelocity.Velocity = CFrame.new(GrappleHook.Position, MousePosition).LookVector * 50GrappleHook.Touched:Connect(function(Part)
if Part:IsDescendantOf(game.Workspace.Map) then
print(Part)
BodyVelocity:Destroy()
GrappleHook.Anchored = true
HasHit = true
local Prompt1 = Instance.new(“ProximityPrompt”)
Prompt1.Parent = StartPart
Prompt1.Triggered:Connect(function(Zipliner)
local Pulley = game.ReplicatedStorage.Pulley:Clone()
Pulley.Parent = game.Workspace
Pulley.Body.CFrame = CFrame.new(StartPart.Position, GrappleHook.Position)
local BodyVelocity2 = Instance.new(“BodyVelocity”)
BodyVelocity2.Parent = Pulley.Body
BodyVelocity2.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BodyVelocity2.Velocity = (Plr.Character.HumanoidRootPart.Position - GrappleHook.Position).Unit * -10
local BodyGyro = Instance.new(“BodyGyro”)
BodyGyro.Parent = Pulley.Body
BodyGyro.CFrame = CFrame.new(StartPart.Position, GrappleHook.Position)
local Weld1 = Instance.new(“WeldConstraint”)
Weld1.Parent = Zipliner.Character
Weld1.Part1 = Pulley.Body
Weld1.Part0 = Zipliner.Character.RightHand
Plr.Character.HumanoidRootPart.CFrame = CFrame.new(StartPart.Position, GrappleHook.Position)
UIS.InputBegan:Connect(function(Key)
if Key.KeyCode == Enum.KeyCode.Space then
end
end)
RS.Heartbeat:Connect(function()
if (Plr.Character.HumanoidRootPart.Position - GrappleHook.Position).Magnitude < 2 then
print(“in range”)
if Plr.Character.HumanoidRootPart:FindFirstChild(“BodyVelocity”) then
Plr.Character:FindFirstChild(“HumanoidRootPart”):FindFirstChild(“BodyVelocity”):Destroy()
end
end
end)
end)
end
end)local Origin = StartPart.Position
local Direction = StartPart.CFrame.LookVector * 30local NewRay = Ray.new(Origin, Direction)
local MidPoint = NewRay.Origin + NewRay.Direction/2
local Part = Instance.new(“Part”)
Part.Parent = StartPart
Part.Anchored = true
Part.CanCollide = false
Part.Name = “ZiplinePole”
Part.CFrame = CFrame.new(NewRay.Origin, MidPoint)
Part.Size = Vector3.new(1, NewRay.Direction.Magnitude, 1)
Part.Transparency = 0
end)