Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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

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. RynKatze 32 — 6y
Ad

Answer this question