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

How do I add Fire and BodyColor Changing to this Script?

Asked by
SirPaco 66
9 years ago

I created a Script that kills any Humanoid when they touch the Part but I do not know how to set the Player on Fire and turn all of their BodyColors to the color of Black.

script.Parent.Touched:connect(function(hit)
    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid.Health = 0
    end
end)

2 answers

Log in to vote
0
Answered by 9 years ago

You would have to make a variable making the fire, sparkles, or smoke. This is how you would do it.

particles = Instance.("Fire",hit.Parent.Torso)

The full script would be:

script.Parent.Touched:connect(function(hit)
    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid.Health = 0
    particles = Instance.new("Fire",hit.Parent.Torso)
    end
end)

You can replace fire with Sparkles, Smoke, and ParticleEmitter

0
What about the BodyColor though? SirPaco 66 — 9y
0
Did not even work. Thank you anyway. SirPaco 66 — 9y
0
What colors? docrobloxman52 407 — 9y
0
Sir I just edited it try it now docrobloxman52 407 — 9y
View all comments (4 more)
0
It works now docrobloxman52 407 — 9y
0
Thanks but I still need to change the body color. SirPaco 66 — 9y
0
Okay what colors? docrobloxman52 407 — 9y
0
Black for all. Also, is it possible to identify Left Arm, Right Arm, Left Leg, and Right Leg in a Script? SirPaco 66 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

(This is in addition to docrobloxman52's answer)

To turn all of the character's parts black, you can iterate over the character's parts:

parts = hit.Parent:GetChildren()
for i = 1, #parts do
    if parts[i]:IsA("BasePart") then
        parts[i].BrickColor = BrickColor.new("Black")
    end
end

(Regarding your comment) If you wish to access a specific part with a space in the name, you can use :FindFirstChild to make sure it's there, or simply use hit.Parent["Left Arm"] (but that will error if Left Arm doesn't exist). So, if you wanted to change their Left Arm to Red, you might do:

local leftArm = hit.Parent:FindFirstChild("Left Arm")
if leftArm then
    leftArm.BrickColor = BrickColor.new("Bright red")
end
0
I am only interested in the second Script because it is the only one I understand but I do not know how to add it to the Script. SirPaco 66 — 9y
0
Put it after line 4 in docrobloxman52's script chess123mate 5873 — 9y

Answer this question