Whoops, didn't see that I even used the parameter, however, you guys still helped me with it. Thanks and sorry for a unneeded question.
I'm having trouble with the player parameter. That means that when I ever use the player parameter, I get a error that "Player" is not a valid object. Is this parameter removed? Does it need something defined? When I do:
function joined(player) if player.TeamColor == "Blue" then print(player.Name .. "is in team blue!") end end
I don't know any more about the error, but if someone would be able to help, please tell me what the error is and how to fix it.
Thank you in advance.
Define the player.
In a local script, you can get a player with game.Players.LocalPlayer.
In a normal script, if you're using a touched part, you can use :GetPlayerFromCharacter, or do the long way script.Parent.Parent....
You can also use the PlayerAdded and Player Removing Event.
game.Players.PlayerAdded:connect(function(player) -- You have the player! print("this player "..player.Name" has joined") end)
The problem with your code is that you don't have a connection line that defines what player actually is, assuming that the code you provided is all the code you have.
To fix this and make player actually exist simply add a connection line.
function joined(player) if player.TeamColor == BrickColor.new("Blue") then print(player.Name .. "is in team blue!") end end game.Players.PlayerAdded:connect(joined) -- Our connection line
Another problem with your code that I noticed is that you're trying to compare a TeamColor (a BrickColor value) to a string. You must compare it to another BrickColor value. This is done by adding BrickColor.new()
around the string. I'm also not aware of the color "Blue" existing, however, there is "Bright blue" and "Really Blue".
Good luck!