In my game I have a Sword in my ReplicatedStorage with 3 main components. But when I test this, all 3 components show up, but the FolderParts section is left empty without the sword parts. I tried adding .Sword to local rp and changing the WaitForChild to FolderParts but that just doesn't put the whole model into the Character, just FolderParts. I really can't tell what I did wrong, could I have some advice?

FolderParts - Place holder for sword parts

ScriptWeld - Welds the sword to the Character as an alternative to it being a tool

ScriptDamage - Self-explanatory

Here's a snippet of my code:

local rp = game.ReplicatedStorage.FolderSwords
local Sword = rp:WaitForChild('Sword')

game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(char)

local all,last = {}
function scan(l)
for a,v in pairs(l:GetChildren()) do
	if (v:IsA("BasePart")) then
		if (last) then
			local Weld = Instance.new("ManualWeld")
			Weld.Part0,Weld.Part1 = last,v
			Weld.C0 = v.CFrame:toObjectSpace(last.CFrame):inverse()
			Weld.Parent = last
end
		table.insert(all,v)
		last = v
	end
		scan(v)
	end
end
scan(rp.Sword.FolderParts)
for _,v in pairs(all) do v.Anchored = false 

end

	local ClonedSword = Sword:Clone()
	ClonedSword.Parent = char
	
	ClonedSword.Handle.CFrame = char:WaitForChild('RightHand').CFrame * CFrame.Angles(math.pi/-2,0,0) 
	
	local Weld = Instance.new('ManualWeld')
	Weld.Part0 = ClonedSword.Handle
	Weld.Part1 = char:WaitForChild('RightHand')
	Weld.C0 = ClonedSword.Handle.CFrame:inverse() * char:WaitForChild('RightHand').CFrame 
	Weld.Parent = char:WaitForChild('RightHand')
	
		
	end)
end)



5 comments

1

5 lines isnt enough for us to help

0

Yeah.

0

Sorry about that, I have edited it a bit, but it's still fairly vague.

0

Check you end statements. There should be an end) on line 6

0

Tried that, it wasn't the problem, also using that rendered function(char) useless for it was used after lines 28 as well, worked around it, and still had the same results. Thanks for the help though!