✓ Accepted answer
[^1]: Players service, not the player object
[^2]: The chart for converting brickcolor values is here
#What's the problem?
- The debounce is unnecessary if you're using it this way
- Touched returns the part, not the player
- The team property is not called Team, it's called TeamColor
- TeamColor isn't a string value, it's a BrickColor value
- "Red" isn't a color. Use BrickColor.Red() or "Bright red" instead
#Getting the player from a part
You can use a function of Players[^1]. You have to have the character as one of the parameters and it'll find the player that way.
local character = game.Workspace.Player
local player = game.Players:GetPlayerFromCharacter(character)
if player then
print("Player is " .. player.Name)
else
print("Player doesn't exist!")
end
#TeamColor
The property name is TeamColor. Not Team, and roblox is very sensitive to caps and small typos. Make sure you read through and fix all of them.
#Comparing BrickColors
BrickColors are they're own datatype and is a type of color value. They must either be compared to another BrickColor value or they can be turned into other values[^2].
print(BrickColor.new() == 3)
print(BrickColor.new() == BrickColor.new())
print(BrickColor.White() == 0)
false
true
false
Use words such as "Name" or "Number" or "Color" to convert BrickColor to other values.
#Final Product
local CapturePointA = game.Workspace.CapturePointA
function Touched(part)
local player = game:GetService("Players"):GetPlayerFromCharacter(part.Parent)
if player and player.TeamColor.Name == "Bright red" then
print 'Red person gross'
end
end
CapturePointA.Touched:connect(Touched)
Hope it helps!
2 comments
if player.TeamColor==BrickColor.new('Bright red') then
Please wait while I explain the answer in full detail.