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

Everything spawns in the model, help?!

Asked by 7 years ago

Hey, I'm making an egg hunt and i'm trying to give the egg a separate model so the egg radar can track it, but when the egg spawns, they all spawn in this one model. How do I make separate models for the egg to spawn in separately? Thanks.

while true do


    if script.Parent.Health == 0 then
        local model = Instance.new("Model")
        model.Parent = game.workspace:WaitForChild("Eggs")      

        s = game.Lighting.Eggs.EgglessShadow.Object.ChocolateEgg:Clone()
        s.Parent = game.workspace:WaitForChild("Eggs").Model
        s.CFrame = script.Parent.Parent.UpperTorso.CFrame

        script:Remove()
    end
    wait()
    end

1 answer

Log in to vote
0
Answered by 7 years ago

Change line 9 to be s.Parent = model. Since all the models have the same name, performing ".Model" on line 9 just gets the first one.

Other notes:

  • You needn't use WaitForChild more than once for a single child
  • You should use workspace or game.Workspace (game.workspace is deprecated)
  • You should not use UpperTorso unless you force all players to use the new character models. The old models have a Torso, but no UpperTorso. Both have a HumanoidRootPart, which I believe is in the same position as the torso.
Ad

Answer this question