#Team check script error
11 messages · Page 1 of 1 (latest)
The script worked fine for me. Is it in a LocalScript or Script?
And if possible could you send the whole script?
The script is inside the ServerScriptService, and that's all it's about
How are you getting the player? And are you getting any errors?
game:GetService("Players")
while wait(10) do
if player.Team.Name == "Police officer" then
for i,player in ipairs(game.Players:GetPlayers()) do
player.leaderstats["money"].Value += 100
end
end
end
I add game:GetService("Players")
Output:
ServerScriptService.givemoney:5: attempt to index nil with 'Team' - server - givemoney:5
** You are now Level 2! **
Ah yeah you gotta loop through all the players first. Then check if the player is in the right team
For loop before the if statement
local Teams = game:GetService("Teams")
local PoliceTeam = Teams:FindFirstChild("Police officer")
while task.wait(10)
for _, Player in PoliceTeam:GetPlayers() do
Player.leaderstats["money"].Value += 100
end
end
In your code player does not exist