Problem with positioning welds

Heyo Devforum! I have been scripting a zipline using welds, and I want to weld the player right below the part he/she is supposed to hang on, but it doesn’t work. Can someone please tell me why my script doesn’t work?

repeat wait() until game.Workspace:WaitForChild("Tower of Troubling Tutorials")
local ziplines = game.Workspace:WaitForChild("Tower of Troubling Tutorials").Ziplines:GetChildren()

local tweenservice = game:GetService("TweenService")
local runservice = game:GetService("RunService")

local player = game.Players.LocalPlayer
local playermodule = require(player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"))
local controls = playermodule:GetControls()

for i, zipline in pairs(ziplines) do
	local isonzip = false

	local line = zipline.Line
	local finish = zipline.End
	local start = zipline.Start
	local speed = zipline.Speed
	local slider = script.Slider
	local animation = script.ZiplineHold

	start.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			if not isonzip then
				isonzip = true
				local character = hit.Parent
				local humanoid = hit.Parent.Humanoid
				local sliderclone = slider:Clone()
				sliderclone.Parent = game.Workspace:WaitForChild("Tower of Troubling Tutorials").Ziplines
				sliderclone.PrimaryPart.Position = start.Position
				local sliderpart = sliderclone.SliderPart
				local movingsliderpart = sliderclone.Part
				local weld = Instance.new("Weld")
				weld.Part0 = character.Head
				weld.Part1 = sliderpart
				weld.Parent = sliderpart
				character.Head.CFrame = sliderpart.CFrame * CFrame.new(0,-5,0)
				local tweeninfo = TweenInfo.new(speed.Value)
				local goal = {}
				goal.CFrame = finish.CFrame
				local tween = tweenservice:Create(movingsliderpart, tweeninfo, goal)
				tween:Play()
				local loadanimation = humanoid:LoadAnimation(animation)
				loadanimation:Play()
				coroutine.wrap(function()
					while isonzip and not controls:GetActiveController():GetIsJumping() do
						runservice.Heartbeat:Wait()
					end
					weld:Destroy()
					loadanimation:Stop()
					sliderclone:Destroy()
					isonzip = false
				end)()
				wait(speed.Value)
				weld:Destroy()
				loadanimation:Stop()
				sliderclone:Destroy()
				isonzip = false
			end
		end
	end)
end

I suggest reading:

What you just could do is make C0 the offset from the head you want to use and C1 the offset from the sliderpart.
As far as I know what you meant, I thought you meant that you’re struggling with welding?

1 Like

What do you mean by “doesn’t work”, does anything happen or does the weld not create at all?

The weld definitely is created because the player is attached to the object, but I want it so that the player is attached below the object so that when he/she is on the zipline, it looks like they are hanging onto it.

Tbh I suggest putting a rope between the part the player holds/the player itself
and the part which moves around a rope from one point to another.
This would having to weld it a lot less annoying and easier for you to script than to figure out how to use CFrames and welding.

character.Head.CFrame = sliderpart.CFrame * CFrame.new(0,-5,0)

That will not get you the result you are looking for.
If this is the only thing you want to do for the weld you can use this

weld.C0 = CFrame.new(0, -5, 0)

That will position the sliderpart down 5 studs from the head

2 Likes

Thank you firsttobebear! This was just what I was looking for.

1 Like