Can't Find a Player's TeamColor with a localscript

So I currently have a local script who’s Parent is a tool that’s located in the player starterpack
starterpack

How do I find the Local Player’s TeamColor with the local script?

I tried to find a Local Player’s TeamColor like this but it didn’t work.

local character = script.Parent.Parent.Parent

local player = game.Players:GetPlayerFromCharacter(character)

if player.TeamColor == "Really Red" then

Setting.ProjectileType = "RedTeam"

else

Setting.ProjectileType = "BlueTeam"

end

Edit: Here is the error code:

1 Like
local tool = script.Parent
local character = tool.Parent

local player = game.Players:GetPlayerFromCharacter(character)

tool.Equipped:Connect(function()
if player.TeamColor == "Really Red" then
Setting.ProjectileType = "RedTeam"
else
Setting.ProjectileType = "BlueTeam"
end
end)

try doing this

1 Like

I tried it, but it got the same error message: Players.TheRealCloody.Backpack.Pistol.GunClient:2803: attempt to index nil with ‘TeamColor’

game.Players.LocalPlayer.TeamColor

bc you use a localscript

1 Like

Oh, I see. I got the script working, thanks for the help!

2 Likes