Hello there,
My custom animated sword, is currently breaking after I respawn. I have tried checking the output, putting prints, and using the console inside the game and I still can’t seem to find the problem. If anyone can find an error in one of the scripts please let me know.
Welding Problem (Pictures)
This is the normal weld of the sword
This is what happens after I respawn
Weld code
wait()
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local function newc1(c1, p)
local nc1 = Instance.new("CFrameValue")
nc1.Value = c1
nc1.Name = "c1"
nc1.Parent = p
return c1
end
local function c1Tool()
table.foreach(tool:GetChildren(), function(_, part)
if part:IsA("UnionOperation") or part:IsA("BasePart") then
local c1 = part:findFirstChild("c1") and part.c1.Value or newc1(part.CFrame:toObjectSpace(handle.CFrame), part)
end
end)
end
local function weldTool()
table.foreach(tool:GetChildren(), function(_, part)
if part:IsA("UnionOperation") or part:IsA("BasePart") then
local c1 = part:findFirstChild("c1") and part.c1.Value or newc1(part.CFrame:toObjectSpace(handle.CFrame), part)
local nW = Instance.new("ManualWeld", handle)
nW.Part0 = handle
nW.Part1 = part
nW.C0 = CFrame.new()
nW.C1 = c1
part.Anchored = false
end
end)
end
tool.AncestryChanged:connect(function(child, parent)
if not handle:findFirstChild("ToolWeld") then
weldTool()
end
end)
c1Tool()
weldTool()
If you want to test for yourself
There is some other code inside my tool which I am willing to give if someone things they can find the problem.