I done a script when a player touch a block if he is in a determined team, the team will add a +1 to TeamA or B but when I touch the block it doesnt work. What can be the trouble?
local TeamA = Instance.new("NumberValue")
TeamA.Name = ("TeamA")
TeamA.Value = 0
TeamA.Parent = workspace
local TeamB = Instance.new("NumberValue")
TeamB.Name = ("TeamB")
TeamB.Value = 0
TeamB.Parent = workspace
script.Parent.Touched:connect(function(hit) --Get what made the hit.
--Define player's variable here with the method GetPlayerFromCharacter!
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
script.Parent.BrickColor = Player.TeamColor
wait(.2)
if Player.team == game.Teams.TeamA
then
game.Workspace.TeamA = game.workspace.TeamA.Value + 1
Player.leaderboard.Painted.Value = Player.leaderboard.Painted.Value + 1
end
if Player.team == game.Teams.TeamB
then
game.workspace.TeamB = game.workspace.TeamB.Value + 1
Player.leaderboard.Painted.Value = Player.leaderboard.Painted.Value + 1
end
end)

1 comment
Is the team in the player?