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

How to change brick color to a players team color?

So I'm trying to make it so when you step on a brick it turns into the players team color. Here's the script:

function onTouched(hit) 
	local human = hit.Parent:findFirstChild("Humanoid") 
	if (human ~= nil ) then 
		local Color = hit.Parent.TeamColor
		script.Parent.Color = Color
	end 
end 

script.Parent.Touched:connect(onTouched)

1 answer

✓ Accepted answer

TeamColor is a property of the player object, not the character model. That's the only thing you had wrong.

function onTouched(hit) 
    local human = hit.Parent:findFirstChild("Humanoid") 
    if (human ~= nil ) then 
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        local Color = player.TeamColor
        script.Parent.BrickColor = Color 
    end 
end 

script.Parent.Touched:connect(onTouched)

Hope I helped, if you have any questions please let me know.

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