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

How do I change a model's parent via script?

Asked by
Lyphios 77
4 years ago

So I have a script that is supposed to make a folder's parent the workspace if the player count is less than 2. In the folder, there are 4 bots that follow the player and attack them. here's the script.

players = game.Players:GetChildren()
if #players >= 2 then
    game.ReplicatedStorage.Bots.Parent.new = workspace
end

the problem is that nothing actually happens. can someone please fix the script?

0
Bots.Parent = game.Workspace User#17685 0 — 4y

1 answer

Log in to vote
0
Answered by
P100D 590 Moderation Voter
4 years ago

You don't need the .new

game.ReplicatedStorage.Bots.Parent = game.Workspace

If you need to create a copy of the item, use :Clone() and set the parent of the copy:

game.ReplicatedStorage.Bots:Clone().Parent = game.Workspace
1
Oh, thanks! Lyphios 77 — 4y
Ad

Answer this question