I am trying to check if a player is in a team when they touch a brick.
local teams = game:GetService("Teams") local teamKids = teams:WaitForChild("Kid") script.Parent.Touched:Connect(function(prt) print("I got touched!") local chr = prt.Parent local plr = game.Players:GetPlayerFromCharacter(chr) if prt and chr and plr then print("The thing that touched me is a player!") if plr.Team == teamKids then print("The player that touched me is in the team 'KIDS'!") end end end)
The output I get when I touch the brick:
I got touched!
The thing that touched me is a player!
The thing is it does not say I am in the team 'KIDS' even tho I am 100%. Can even see it in the leaderboard...
I can't seem to find what is wrong.
Hello! I hope this answers your question.. ENJOY
script.Parent.Touched:Connect(function() local teams = game:GetService("Teams"):GetTeams() local plr = game:GetService("Players").LocalPlayer.Character for i,team in pairs(teams) do local players = team:GetPlayers() print(plr.Name.." Is On Team "..team.Name) end end)