How can I make it so when a player that is on a team steps on a block and then it changes color? Ex: Player on red team steps on a block, it turns red. Here is what I have right now:
function Change(hit) local h=hit.Parent:FindFirstChild("Humanoid") if h~=nil then script.Parent.BrickColor = BrickColor.new("Team color") end end script.Parent.Touched:connect(Change)
Here is my script that works:
local part = script.Parent --defines the variable "part" part.Touched:connect(function(hit) -- do stuff when "part" is touched if hit.Parent:FindFirstChild("Humanoid") then -- if the thing that part is touching has a humanoid then (pretty much detects if it's a player) local player = game.Players:FindFirstChild(hit.Parent.Name) -- defines the variable, "player" as the player that touched the part part.BrickColor = player.TeamColor -- changes brickcolor to the player's teamcolor end end)