Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Everything spawns in the model, help?!

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

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.