Best way of scripting a zipline?

So I was working with my builder on our game project. He built a zipline model and I need help on how to script a working zipline. My builder hopes the characters using the zipline is animated though.

I don’t know what is the best way of scripting a zipline. That’s my problem

I have tried using BodyForce but without success. I know it might be the wrong way of doing that.

Any help is appreciated

5 Likes

Well, I’d use Motor6Ds to animate the character easily - follow these steps:

  • Animate the the character by following this tutorial, I recommend appling the Motor6D between the HumanoidRootPart and the zipline:
  • Save the animation and copy the ID
  • When needed to play the animation; apply the Motor6Ds, load the animation and play it. The script would be like:
local Motor = Instance.new("Motor6D")
Motor.Part0 = player.Character.HumanoidRootPart
Motor.Part1 = zipline
Motor.Parent = player.Character.HumanoidRootPart

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://THEID"
anim.Parent = script

local animTrack = player.Character.Humanoid:LoadAnimation(anim)
animTrack:Play()
2 Likes

Mods say I should do my research before I post, so I tested my script this time. Ok so here’s how to use it. Create a server script, a part named “PartA”, and a part named “PartB”. Once you make those three, group them. Now, position PartA’s center point one stud below the high end of the zipline (or the starting end), also do the same for PartB on the end point. Finally, put this in the script:

local a = script.Parent.PartA
local b = script.Parent.PartB
a.Anchored = true
b.Anchored = true
a.CanCollide = false
b.CanCollide = false

a.Touched:connect(function(hit)
	local character = hit.Parent
	if character:FindFirstChildOfClass("Humanoid") then
		local v = Instance.new("RocketPropulsion")
		local g = Instance.new("BodyGyro")
		v.MaxThrust = 4000
		v.MaxSpeed = 30 -- Set to whatever you like.
		v.TargetRadius = 0
		--v.MaxTorque = Vector3.new(400000, 400000, 0)
		local root = character:FindFirstChild("HumanoidRootPart")
		if root == nil then
			return
		end
		root.Anchored = true
		character:MoveTo(Vector3.new(a.Position.X, a.Position.Y - (root.Size.Y * 0.75), a.Position.Z))
		v.Target = b
		local head = character:FindFirstChild("Head")
		if head == nil then
			return
		end
		g.Parent = head
		v.Parent = head
		root = character:FindFirstChild("HumanoidRootPart") --repeating again just to check if it still exits
		if root == nil then
			return
		end
		local humanoid = character:FindFirstChild("Humanoid")
		if humanoid == nil then
			return
		end
		v:Fire()
		humanoid.PlatformStand = true
		root.Anchored = false
		repeat
			wait()
		until (b.Position - root.Position).magnitude <= 5 --The 5 is how many studs away from part b before it stops.
		humanoid.PlatformStand = false
		v:Remove()
		g:Remove()
	end
end)

There’s no animation yet, but I’m sure you can add that your self. It’s also a bit iffy with the rotation but if you play around with it enough, you should get it right.

8 Likes

Does not work, I literally repositioned and double checked the script 20 times and it does not work

Did you follow the instructions I gave in the post?

Note that this script only works for a straight zipline. What do you exactly mean by ‘does not work’ ?