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 8 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.

01while true do
02 
03 
04    if script.Parent.Health == 0 then
05        local model = Instance.new("Model")
06        model.Parent = game.workspace:WaitForChild("Eggs")     
07 
08        s = game.Lighting.Eggs.EgglessShadow.Object.ChocolateEgg:Clone()
09        s.Parent = game.workspace:WaitForChild("Eggs").Model
10        s.CFrame = script.Parent.Parent.UpperTorso.CFrame
11 
12        script:Remove()
13    end
14    wait()
15    end

1 answer

Log in to vote
0
Answered by 8 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