Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make a script only work for a specified team ?

Asked by 2 years ago
Edited 2 years ago

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:

01function onPlayerEntered(newPlayer)
02 
03    local stats = Instance.new("IntValue")
04    stats.Name = "leaderstats"
05 
06    local cash = Instance.new("IntValue")
07    cash.Name = "Kaproue"
08    cash.Value = 10
09 
10    cash.Parent = stats
11    stats.Parent = newPlayer
12 
13while true do
14        wait(60)
15        cash.Value = cash.Value + 5
View all 24 lines...

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

1 answer

Log in to vote
2
Answered by 2 years ago

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

1while wait() do
2for i, v in pairs (game.Teams:WaitForChild("TEAM_NAME"):GetPlayers()) do

Hope this helps!!

Ad

Answer this question