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

Reversing the effect of this script?

Asked by 9 years ago
bin = script.Parent

function onTouched(part)
    part.BrickColor = script.Parent.BrickColor ---Meaning it'll change color of character to whatever the brick color is.
    wait(.5) ---Time it waits until it changes your body's color.
end

connection = bin.Touched:connect(onTouched)

Okay. So what this script does, is whatever object the character touches, it turns the characters body parts into that objects color. But what I want to know is how do I reverse the effects, so that when the character touches the object, the object turns into the characters (torso) color. Thanks! :)

1 answer

Log in to vote
0
Answered by 9 years ago

Its really quite easy once you think it through. Most important, probably confusing aspect is passing the parameter hit. hit is assigned to the part that touched the bin(ex. Right Leg, Left Leg).Next we check if hit is a valid character and NOT a bullet or other thing, then we simply change the brick color, be sure to use BrickColor.new, you could also use Color3.new(http://wiki.roblox.com/index.php?title=Color3), however you MUST convert brickcolor to color three since torso takes only brickcolor values.

bin = script.Parent

function onTouched(hit)
    if hit.Parent and hit.Parent:WaitForChild("Humanoid") do -- Checks to see if hit is a member of a       player's character
        hit.Parent:WaitForChild("Torso").BrickColor = BrickColor.new(bin.BrickColor) -- Sets torso color to the color of the brick
end

connection = bin.Touched:connect(onTouched)

You could also add "and hit.Parent:WaitForChild("Torso")" at line 4, but go figure if the character has a humanoid, chances are he/she has a torso as well :P. Hope this helps, let me know if this doesn't work!

0
It doesn't work... :I Superbob16 0 — 9y
0
Ok, ill take a look at it again tomorrow dragonkeeper467 453 — 9y
Ad

Answer this question