Delay in setting weld

i dont know if its the C0 and C1 offsets or what but whenever i weld the player to the edge of the top of the part it has a the offsets are delayed or something and it welds the player a few studs to low.

anyone know a fix?

local RunningPlayers = {}
local AnimModule = require(script.Parent.LoadAnim)
local ParkourCheck = require(script.Parent.ParkourCheck)

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local weld = Instance.new("Weld")
		local humanoid = char:WaitForChild("Humanoid")
		local track = AnimModule.LoadingAnimation(humanoid, game.ReplicatedStorage.Animations.ClimbM.AnimationId)
		local jumpForce = math.sqrt(2 * workspace.Gravity * game.Workspace.Part.Size.Y)
		local humRoot = char:WaitForChild("HumanoidRootPart")
		print("HumanoidRootPart AssemblyLinearVelocity:", humRoot.AssemblyLinearVelocity)

		humanoid.Running:Connect(function(speed)
			if speed > 0 then
				if RunningPlayers[plr.UserId] then return end
				RunningPlayers[plr.UserId] = true
				print("Player is running")

				local value, face = ParkourCheck.CheckPart(game.Workspace.Part, humRoot)
				print("CheckPart result:", value, face)

				if value == true then
					plr.PlayerGui.ClimbPrompt.Enabled = true
				end

				if humRoot then
					task.wait(0.1)

					if value == true and RunningPlayers[plr.UserId] == true then
						humRoot.AssemblyLinearVelocity = Vector3.new(0, jumpForce, 0)
						weld.Part0 = humRoot
						weld.Part1 = game.Workspace.Part

						local connection
						connection = game:GetService("RunService").Heartbeat:Connect(function()
							print("Player Y Position:", humRoot.Position.Y)
							print("Part Y Position:", game.Workspace.Part.Position.Y)
							print("Difference in Y Position:", math.abs(humRoot.Position.Y - game.Workspace.Part.Position.Y))
							if math.abs(humRoot.Position.Y - game.Workspace.Part.Position.Y) < 0.1 then
								weld.C0 = humRoot.CFrame:inverse() * humRoot.CFrame
								weld.C1 = game.Workspace.Part.CFrame:inverse() * humRoot.CFrame
								weld.Parent = game.Workspace.Part
								print("Weld parented to part")
								plr.PlayerGui.ClimbPrompt.Enabled = true
								if track and not track.IsPlaying then
									track:AdjustSpeed(-2)
									track:Play()
									print("Animation played")
								end
								connection:Disconnect()
							end
						end)
					else
						print("Player is not in the area")
						print(face)
						plr.PlayerGui.ClimbPrompt.Enabled = false
					end
				end

				task.delay(1, function()
					RunningPlayers[plr.UserId] = false
					print("RunningPlayers reset")
				end)
			end
		end)
	end)
end)

nvm im just not very smart, it was cause the player stops halfway, i forgot to multiply it by 2
:expressionless:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.