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?
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