Hi, I am making a module that tweens and reset welds and I have run into this error:
But when I look into the player, “RIght Shoulder” already exists even before the error.
Module script:
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Torso = character:WaitForChild("Torso")
local Head = character:WaitForChild("Head")
local RA = character:WaitForChild("Right Arm")
local LA = character:WaitForChild("Left Arm")
local RL = character:WaitForChild("Right Leg")
local LL = character:WaitForChild("Left Leg")
function Tween.TweenWeld(TargetLimb, StartCFrame, CFrame0, EasingDirection, EasingStyle, Duration)
EditLimb:FireServer(TargetLimb, CFrame0)
local weldExists = false
local weld = nil
local appendiges = {RA, LA, RL, LL, Head}
local correspondingJoints = {Torso:WaitForChild("Right Shoulder"), Torso:WaitForChild("Left Shoulder"), Torso:WaitForChild("Right Hip"), Torso:WaitForChild("Left Hip"), Torso:WaitForChild("Neck")}
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()
end
end
end
Any help would be appriciated, thanks!