Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you make a team on touched event for a part to change its brickcolour?

Asked by
RO_LEWIS -58
4 years ago
Edited 4 years ago

I was trying my hardest to make an on touched team brickcolour event but just can’t quite get it. I need a part to change to the colour of the player’s team colour for instance, if the player is on yellow team the brickcolour of the object will change to yellow?

1 answer

Log in to vote
1
Answered by
royaltoe 5144 Moderation Voter Community Moderator
4 years ago

Check the players team when the player touches a part:

part = game.Workspace.Part

part.Touched:Connect(function(hit)
        --see if the thing being touched is the players character by looking for the characters name in game.Players 
        local player = game.Players:FindFirstChild(hit.Parent.Name)
         if(player)then
                 --if you look on the wiki, team color is a brick color
                 -- which means we can assign it to the parts color
                 part.BrickColor = player.Team.TeamColor
         end

end)
Ad

Answer this question