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