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