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

Help with lighting body parts on fire?

Asked by 6 years ago
Edited 6 years ago

This is a small portion of a fireball script I'm working on, I want to make it so that on contact, it lights the player on fire(All of their body parts). How would I make it so that the particle emitters position matched that of the body parts.

 fireball.Touched:connect(function(hit)
 local fire = game.Lighting.ParticleEmitter:Clone()
  for i,v in pairs(hit.Parent:GetChildren()) do

Using this script, I tried to make it so that the Particle emitter would be inserted into each thing inside a character. But it did not work. Instead, the particle emitter(s) is/are laying on the baseplate and I have no idea where in the explorer they are located.

In short, the question is how can I position particle emitters to be where I want them to (With most things I use (Object).CFrame = (OtherObject).CFrame)

0
I mean I could always just individually put all the particle emitters in the body parts in separate lines of code, but that takes up unnecessary space. DominousSyndicate 41 — 6y
0
Why is the particleemitter in Lighting? User#19524 175 — 6y
0
I dont really know, just a simple place to store it, where do you think I should put it? DominousSyndicate 41 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

You're on the right track. You're using a for loop to iterate through hit.Parent's children. What's left is to clone the particle emitter. Also, don't use Lighting as storage as we have services like ServerStorage to use as storage. Using Lighting to store things is unsupported by ROBLOX.

local fire = game:GetService("ServerStorage").ParticleEmitter

fireball.Touched:Connect(function(part) -- uppercase C
    for _, v in pairs(part.Parent:GetChildren()) do
        if v:IsA("BasePart") then -- if it's a part
            if not v:FindFirstChild("ParticleEmitter") then -- don't want to spam
                fire:Clone().Parent = v -- clone fire and parent to the part
            end
        end
    end
end)
0
There's still a couple things I don't understand, why use "GetService" for ServerStorage? Couldn't you just do game.ServerStorage.ParticleEmitter? DominousSyndicate 41 — 6y
0
Also, whats the difference between a Part and a BasePart? DominousSyndicate 41 — 6y
0
BasePart is the base class for all part objects (Part, Seat, PartOperation, etc.). Those classes inherit from BasePart, so if we use IsA, we can check if the child inherits from the class. In this case we want to check if the child is a part. And I use GetService as game.Service is prone to script error, should the desired service be renamed. GetService returns a service by its ClassName, it creat User#19524 175 — 6y
Ad

Answer this question