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

Cloning a model to workspace is not working?

Asked by
zomspi 541 Moderation Voter
4 years ago

I am making a clone script which isn't working and I think it is because it is a model, is there any way to clone a model? If this is not the case could you please tell me what is wrong with this script? Thanks!

My current script

local Enemies = script.Parent.Enemies

game:WaitForChild("Players").PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)

    Enemies.Dark:Clone().Parent = game.Workspace.Enemies
    Enemies.Dark1:Clone().Parent = game.Workspace.Enemies
    Enemies.Dark2:Clone().Parent = game.Workspace.Enemies
    Enemies.Dark3:Clone().Parent = game.Workspace.Enemies
    Enemies.Dark4:Clone().Parent = game.Workspace.Enemies
    Enemies.Dark5:Clone().Parent = game.Workspace.Enemies
    while true do
wait(1)
    if char.Humanoid.Health == 0 then
        Enemies.Dark:Clone().Parent = game.Workspace.Enemies
    Enemies.Dark1:Clone().Parent = game.Workspace.Enemies
    Enemies.Dark2:Clone().Parent = game.Workspace.Enemies
    Enemies.Dark3:Clone().Parent = game.Workspace.Enemies
    Enemies.Dark4:Clone().Parent = game.Workspace.Enemies
    Enemies.Dark5:Clone().Parent = game.Workspace.Enemies
    end
end
end)
end)



1 answer

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

First of all, try parenting your clones into Workspace instead of something within Workspace. Also, you might get a lot of them to spawn at once when doing "while true do" but you can resolve that later.

Also, instead of doing a ".Parent" thing for clones, just put it in between those brackets. It literally parents it to it.

So instead of this:

:Clone().Parent = ...

Do this:

:Clone(game.Workspace)

One last thing: make sure that you are doing this in a Script and not a LocalScript as this is a somewhat common issue.

If you have any questions or issues please contact me. ;)

0
Thanks, I had no idea that was what the brackets were for zomspi 541 — 4y
0
If this is the correct answer please accept it. I just would like to keep track of what I fixed or has been fixed (it helps others too). lazycoolboy500 597 — 4y
0
I just tested it and it didn't work zomspi 541 — 4y
0
What happens when you run it? Any errors? lazycoolboy500 597 — 4y
View all comments (2 more)
0
I get no errors zomspi 541 — 4y
0
Are you running this on a normal script? Also, did you make sure the script is either in ServerScriptService, Workspace, StarterCharacterScripts, or StarterPlayerScripts? lazycoolboy500 597 — 4y
Ad

Answer this question