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

How can I make this Explosion?

Asked by 10 years ago

How do you make it so if something Explodes; there becomes a Sphere that basically appears at the explosion? I only know how to do the instance.new I cannot mannage to exactly make the two functions cooperate together.

1 answer

Log in to vote
2
Answered by
Ekkoh 635 Moderation Voter
10 years ago

You don't need to make "two functions cooperate", you just write your code like you normally would. You probably are looking for something like this maybe?

function explode(pos) -- I'd make a function for it
    local sphere = Instance.new("Part")
    sphere.Shape = Enum.PartType.Ball
    sphere.CanCollide = false
    sphere.Anchored = true
    sphere.Size = Vector3.new(25, 25, 25)
    sphere.Transparency = .7
    sphere.BrickColor = BrickColor.Yellow()
    sphere.CFrame = CFrame.new(pos)
    local exp = Instance.new("Explosion")
    exp.Position = pos
    sphere.Parent = Workspace
    exp.Parent = sphere
    Game:GetService("Debris"):AddItem(sphere, 3)
end

-- Ex:
explode(Vector3.new(0, 0, 0))

Part.Touched:connect(function() -- A usage example
    explode(Part.Position)
end)
0
I've upvoted you, but please change your script's line 14 to be 'game:GetService("Debris"):AddItem(sphere,3)'. It's a better solution. TheLuaWeaver 301 — 10y
0
And why is that a better solution? Ekkoh 635 — 10y
0
Never question the Weaver. The last one to question 'It' has never been seen again. ConnorVIII 448 — 10y
0
I'll try my luck :p Ekkoh 635 — 10y
Ad

Answer this question