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

How would I clone an object and then modify 2 attributes instead of just one?

So I want to clone an object, modify its parent and then modify its position to the current part's, then destroy the object. When a value goes under 0. Heres what I used:

if script.Parent.NumberValue.Value <= 0 then
	Clone1 = game.ReplicatedStorage.InterestingParts.Part2:Clone()
	Clone2 = game.ReplicatedStorage.InterestingParts.Part1:Clone()
	Clone1.Position = Vector3.new(script.Parent.Position)
	Clone1.Position = Vector3.new(script.Parent.Position)
	Clone2.Position = Vector3.new(script.Parent.Position)
	Clone2.Position = Vector3.new(script.Parent.Position)
	script.Parent:Destroy()
end

This doesnt work and Im not sure why, can anyone help?

1 answer

✓ Accepted answer

The reason your script isn't working is because you need to parent the objects to something. Right now their floating in empty space, Try Adding This:

local parentTo = game.Workspace --you can change this parent to whatever you want, and the parts will be parented to it
Clone1.Parent = parentTo
Clone2.Parent = parentTo

The problem is, when objects our cloned, their parent is nil, or nothing. They don't automatically get assigned, so you have to set their parent. Hope I could help, comment on this if you have any questions, and have a great day.

-REALTimothy0812

1 comment

0

Just tried it and it still doesn’t work. I have found the problem, which was that it only checked once so I set up a function to check. Thank you though.

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