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

How to add children to instance.new()?

I am new to scripting and I am trying to make an instance.new() script but I have trouble adding children to the part~~~~~~~~~~~~~~~~~

wait(10)
dangerouspart = Instance.new("Part",game.Workspace)
dangerouspart.Anchored = false
dangerouspart:GetChildren() ----- this is the part where i am having trouble adding a child, damaging script.

2 answers

local Brick = Instance.new("Part")
Brick.Parent = game.Workspace
Brick.Name = "DangerousPart"
Brick.Anchored = false

local ScriptToAdd  = game.ReplicatedStorage:Clone()
ScriptToAdd.Parent = Brick

for, i v in pairs (game.ReplicatedStorage:GetChildren()) do -- change this to whatever group you are trying to clone into the said brick.
	v:Clone().Parent = Brick
end)

Not sure if this is what you are asking?

2 comments

0

No i am asking how to add children, not to clone the part. Like how a gun fires (Warbound for example) it has a light in it.

0

You can still add children by cloning them from another Service and into the part, just like what Decimaprism did.

Try this:

wait(10)
local dangerousPart = Instance.new("Part",game.Workspace)
dangerousPart.Anchored = false

local dangerousPartChildren = {
	"Part", -- Children that you want to add to the dangerousPart
	"Part"
-- And so on... however many children you want to have
}

for _, v in pairs(dangerousPartChildren) do
	Instance.new(v)
	v.Parent = dangerousPart
end

I read your comment to Decimaprism but didn't have space to add this. However, if you want a flash (if that's what you mean by light), you'll need to insert a BillboardGui into the gun. Then insert an ImageButton into the BillboardGui. Change the image property in ImageButton to what you would like your flash to look like. Keep the Gui invisible until the player shoots the gun. Make sure the script in your gun enables the BillboardGui (or makes the ImageButton visible) when your gun is activated, and that the flash lasts for a VERY short amount of time if that's what you want.

Hope this helps!

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