Welds break on respawn

Hi, I have a module where it edits a character’s weld. It works usually, but when a player respawns, it breaks and doesn’t give any erorrs.

The module script:

function Tween.TweenWeld(TargetLimb, StartCFrame, CFrame0, EasingDirection, EasingStyle, Duration)
	local weldExists = false
	local weld = nil
	local appendiges = {RA, LA, RL, LL, Head}

	local correspondingJoints = {Torso:WaitForChild("Right Shoulder" , .2), Torso:WaitForChild("Left Shoulder"  , .2), Torso:WaitForChild("Right Hip"  , .2), Torso:WaitForChild("Left Hip"  , .2), Torso:WaitForChild("Neck"  , .2)}

	local EndCFrame = {}
	EndCFrame.C0 = CFrame0 

	local Info = TweenInfo.new(Duration,EasingStyle,EasingDirection)

	for _, v in pairs(Torso:GetChildren()) do
		if v.Name == "Weld" and v.Part1.Name == TargetLimb then
			weldExists = true
			weld = v
		end
	end

	if not weldExists then
		weld = Instance.new("Weld")
	end 

	for i,v in pairs(appendiges) do
		if TargetLimb == v.Name then
			correspondingJoints[i].Part1 = nil

			weld.Parent = Torso
			weld.Part0 = Torso
			weld.Part1 = v
			weld.C0 = StartCFrame
			local Animation = TweenService:Create(weld, Info, EndCFrame)
			Animation:Play()
			EditLimb:Fire("Tween" , TargetLimb, StartCFrame, CFrame0, EasingDirection, EasingStyle, Duration)
		end
	end
end

Any help would be appreciated, thanks!

3 Likes

Can you give more context on what the script is used for and its purpose?

2 Likes

Ok, here is a sample code of what I use this module for:

local Direction = Enum.EasingDirection.Out
local Style = Enum.EasingStyle.Sine

local CFRAME_HERE_RL = CFrame.new(0.5,-1.5,-0.7) *  CFrame.fromEulerAnglesXYZ(0.64,0,0)
local CFRAME_HERE_LL = CFrame.new(-0.5,-1.5,-0.7) *  CFrame.fromEulerAnglesXYZ(0.64,0,0) 

Tween.TweenWeld("Right Leg", CFrame.new(0.5,-2,0), CFRAME_HERE_RL, Direction, Style, 0)

If you want more code, just ask.

2 Likes

I meant like what were you trying to accomplish. I don’t need the code. I’m just confused why you’re trying to edit the player’s welds.

1 Like

Because I want to move the players leg for example, to a specific c-frame smoothly, so I use welds along with tweens, and also so other players can see the players tween.

1 Like

If you’re trying to animate the legs, then I’d suggest just making an animation rather than editing the player’s legs.

1 Like

It is simpler to tween the players legs rather than to make an animation for every single script I have though.

1 Like

im not completely sure i understand what you’re doing but would using Motor6D.Transform do what you’re trying to accomplish?

Everything works… it just that the module breaks when you respawn the character, and I was looking for some help on how I could solve it.

I literally have no idea what any of this means, but I’m assuming the script cant run when the character loads as it still thinks the older one is in workspace. I may be horribly wrong though.

how do i tackle this? I think this may be the issue as the module is in replicatedstorage

You can probably re-run the TweenWeld function when they respawn, I don’t know though

I ended up fixing it by running RunService.Stepped:Wait() at the top of the module, thanks for the help everyone.

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