Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Trying to make part's position same as another one, keeps producing errors, any help over here?

Just be reading the script you'll understand that I'm trying to get replace an old part with a new one and making it have the same position:

BladeEvent.OnServerEvent:Connect(function()
	local previousblade = BladesFolder:GetChildren()
	local BladeClone = Blade:Clone()
	BladesFolder:ClearAllChildren()
	BladeClone.Parent = BladesFolder
	BladeClone.CFrame = CFrame.new(0, 5, 0):toWorldSpace(previousblade)
end)

Sadly, it keeps telling me this error: ** bad argument #1 to 'toWorldSpace' (CFrame expected, got table)**

If you don't mind explaining me what have I done wrong so I can better understand the new code, and not make the same mistake again, thank you! G'day y'all!

1 answer

✓ Accepted answer

The error is obvious. :toWorldSpace() expects a CFrame to be passed, and what you are passing is a table of BladesFolder's children (previousblade is a table, not a part).

local previousblade = BladesFolder:GetChildren()
...
BladeClone.CFrame = CFrame.new(0, 5, 0):toWorldSpace(previousblade)

But I'm not sure why would you even use CFrames. You could just set its position, like so:

BladeClone.Position = Blade.Position

1 comment

0

I tried position but it ends doing it next to the character somehow, I'll try it again and see.

This discussion is preserved as it was. New answers, comments, and votes are closed.