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

I can't make this script work for certain group role 3+, just for all members?

Asked by 5 years ago
Edited 5 years ago

My script adds 1 point into a player leaderstat every 1 minute if they are in a group. I have tried but I cannot seem to get it to only give it if they are rank number 3 or higher. Can someone please help? Here is the script:

01local DataStore = game:GetService("DataStoreService")
02local ds = DataStore:GetDataStore("CashSaveSystem")
03 
04game.Players.PlayerAdded:connect(function(player)
05 
06    local leader = Instance.new("Folder",player)
07    leader.Name = "leaderstats"
08 
09    local currency = Instance.new("IntValue",leader)
10    currency.Name = "Points"
11    currency.Value = ds:GetAsync(player.UserId)
12 
13    ds:SetAsync(player.UserId, currency.Value)
14 
15    currency.Changed:connect(function()
View all 33 lines...
0
Shouldn't you like make this script separate in serverscriptservice I suggest make it separate then trying again DuckyRobIox 280 — 5y

1 answer

Log in to vote
1
Answered by
Epuuc 74
5 years ago
Edited 5 years ago

Change line 29 Player:IsInGroup(ID) to Player:GetRankInGroup(ID) >= 3

IsInGroup returns a bool value if they're in the specified group. GetRankInGroup returns a number of the rank of the player in the group. You can use that number to check it's greater than a number, and if it is, then do the rest of the code.

0
Thanks! This helped. OrbitOps 34 — 4y
Ad

Answer this question