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

How To Fix A Touched Event Color Changer?

Asked by 6 years ago

Alright, I am new to scripting so this is one of my first touched events. Basically, I am trying to get the brick to turn my legs red when I walk over it. Here is the source. For whatever reason, my legs are not turning red, I was wondering how to fix this?


function touched(hit) hit.BrickColor = BrickColor.new("Bright red") end script.Parent.Touched:connect(touched)

Again, I understand it is a basic script but I have recently started, any help would be appreciated.

1
"hit" is the object that touched the scripts parent, if you're trying to change the part that was touched, change it to script.Parent.BrickColor = BrickColor.new("Bright red") gmatchOnRoblox 103 — 6y
1
Your code looks and ran fine for me. Is the script inside a part? Are you sure that it is NOT changing the color of the part - the Pants item could hide the Leg's color. PreciseLogic 271 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

ROBLOX changed how body colors worked so that you can no longer change body colors by just changing brick color. This is now controlled by an object called, "Body Colors". Basically what's going is the script is checking if part that touched's parent is a player. Then if that is true then it goes ahead and changes the Left Leg and Right Leg color.

Try something like this:

function touched(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent["Body Colors"].LeftLegColor = BrickColor.new('Bright red')
        hit.Parent["Body Colors"].RightLegColor = BrickColor.new('Bright red')
    end
 end

script.Parent.Touched:connect(touched)

Hope this helps!

0
No, shirts and pants hide those limbs. Besides parts where you have no clothing, this will not take an effect. hiimgoodpack 2009 — 6y
Ad

Answer this question