I want to make my code only work for one team so none of the players that are not in the specified team can use this script
The code:
function onPlayerEntered(newPlayer) local stats = Instance.new("IntValue") stats.Name = "leaderstats" local cash = Instance.new("IntValue") cash.Name = "Kaproue" cash.Value = 10 cash.Parent = stats stats.Parent = newPlayer while true do wait(60) cash.Value = cash.Value + 5 end end game.Players.ChildAdded:connect(onPlayerEntered)
The script is a regular script not a local script the script adds 5 "Kaproue" or money to the player every minute, I want to make it add the money to only players in a specified team
Hi there here is an example of code to use for a certain team. You will need to make adjustments to the code and edit it to your preference make sure you change Team_Name to the team name you want to have the code work for. Also I believe the script should go in serverscriptservice
while wait() do for i, v in pairs (game.Teams:WaitForChild("TEAM_NAME"):GetPlayers()) do
Hope this helps!!