Body Color Changer

Hello, I’ve been wondering how to do this for a while. It works in studio but not in-game, and I’ve tried doing both a localscript and a server script.

Here’s the code I’ve been trying to use:

local part = script.Parent

function OnTouched(partThatTouched)
local isAPlayer = partThatTouched.Parent:FindFirstChild(“Humanoid”)
if isAPlayer then
local character = partThatTouched.Parent
character.leftupperarm.BrickColor = BrickColor.new(“Persimmon”)
character.rightupperarm.BrickColor = BrickColor.new(“Persimmon”)
character.leftupperleg.BrickColor = BrickColor.new(“Persimmon”)
character.rightupperleg.BrickColor = BrickColor.new(“Persimmon”)
end
end
part.Touched:Connect(OnTouched)

Block of codes!

local part = script.Parent

function OnTouched(partThatTouched)
	local isAPlayer = partThatTouched.Parent:FindFirstChild("Humanoid")
	if isAPlayer then
		local character = partThatTouched.Parent
		character.leftupperarm.BrickColor = BrickColor.new("Persimmon")
		character.rightupperarm.BrickColor = BrickColor.new("Persimmon")
		character.leftupperleg.BrickColor = BrickColor.new("Persimmon")
		character.rightupperleg.BrickColor = BrickColor.new("Persimmon")
	end
end
part.Touched:Connect(OnTouched)

Its just your code but in block of codes.(Will affect nothing.)

1 Like

I don’t know what block of codes is, please elaborate

Are you referring to color codes?

Why not use BodyColors to change the colour of each part?

I’m using a custom character I made

1 Like

What is not working here? Also by block of codes he meant formatting your script like this:

print("Hello World")

I still don’t get the problem here. Also, is it local script or server script?

I’ve tried both a local and server script and neither work. It works in-studio but not in-game

Are you using Unions for the custom character? Make sure you check for UsePartColor is set to true.

There are no unions in my character

It’s not working because you didn’t correctly name the bodyparts.
Try this

local part = script.Parent

function OnTouched(partThatTouched)
	local isAPlayer = partThatTouched.Parent:FindFirstChild("Humanoid")
	if isAPlayer then
		local character = partThatTouched.Parent
		character.["LeftUpperArm"].BrickColor = BrickColor.new("Persimmon")
		character.["RightUpperArm"].BrickColor = BrickColor.new("Persimmon")
		character["LeftUpperLeg"].BrickColor = BrickColor.new("Persimmon")
		character.["RightUpperLeg"].BrickColor = BrickColor.new("Persimmon")
	end
end
part.Touched:Connect(OnTouched)