I want to put an explosion inside of a Part that just got made.
p = Instance.new("Part",game.Workspace) p.Name = "ScriptMadePart" p.Anchored = true p.Position = Vector3.new(-22, 11.7, 11) wait(1) e = Instance.new("Explosion", game.Workspace.ScriptMadePart)
I do have an Explosion occur. Although, it's in the middle of Game. I want the explosion to become a child of ScriptMadePart. I tried doing the ("Explosion",game.Workspace.ScriptMadePart) but didn't work. I know this must be simple, sorry.
Since 'p' is your variable assigned to the part you just made, you could set the parent of the explosion to it.
e = Instance.new("Explosion", p)
UPDATE
What you should be concentrating on, concerning the position of the explosion, is the 'Position' property.
For example:
e.Position = p.Position
This will set the position of the explosion to the new part you've created.
Putting an explosions in a part does not make the explosions move to the part position. You have to set Explosion.Position
to the part's position.
The correct code is:
local Part = Instance.new("Part",workspace)--// No need for game.Workspace, just use workspace. Tip from me to you ;) Part.Name='ScriptMadePart'; Part.Anchored=true; Part.CFrame=CFrame.new(-22,11.7,11);--// Use CFrame, it's more precise. delay(1,function()--// Spawn a thread in the thread scheduler to make your script more proficient. local Explosion=Instance.new('Explosion',Part); Explosion.Position=Part.CFrame.p;--// This was what you were missing. end);
By doing Explosion.Position=Part.CFrame.p
( you could also do Explosion.Position=Part.Position
), you set the explosion's position to the part's position.