Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How To Fix A Touched Event Color Changer?

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.

2 comments

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")

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.

1 answer

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!

1 comment

0

No, shirts and pants hide those limbs. Besides parts where you have no clothing, this will not take an effect.

This discussion is preserved as it was. New answers, comments, and votes are closed.