I am making promotions based off of points for my group, Krogers. But when you get in the game it doesn't give you points even after you stay in the game for like 20 minutes. Here is my script.
--] Make sure you have your game published and API turned on before you test, if it is not published you will not see it and in output it will say "Can't access datastore blah blah" local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local DataStoreService = game:GetService("DataStoreService") local PointsStore = DataStoreService:GetDataStore("KrogerPoints") -- Keep this name as your own and change if you want to reset point leaderboards. -- If you change the name of the datastore the points will reset. local GamePassx2Id = 7020772 -- Replace these with your two gamepass ID's local GamePassx5Id = 7020770 -- The following below are variables, you can change all of these. local DefaultPoints = 2 -- How many points you earn each time local MinRank = 3 -- The mimimum group rank that can earn points local WaitTime = 75 -- The amount of seconds between each point local GroupId = 4853203 -- Paste your group ID into here. -- This bit is the main script, I would suggest not changing this unless you know ROBLOX LUA. (scripting language) game:GetService("Players").PlayerAdded:Connect(function(Player) local Folder = Instance.new("Folder",Player) Folder.Name = "leaderstats" -- Make sure the name is "leaderstats" all lower case. local Points = Instance.new("IntValue",Folder) Points.Name = "Worker Points" -- If you want the leaderboard to display as something other then "Points" like "Cash" change this, keep the speech marks though. local success, currentPoints = pcall(function() return PointsStore:GetAsync(Player.UserId) end) if success then Points.Value = currentPoints end local GroupRank = Instance.new("StringValue",Folder) GroupRank.Name = "Rank" -- If you want the leaderboard to display as something other then "Rank" change this, keep the speech marks though. GroupRank.Value = Player:GetRoleInGroup(GroupId) local UpdatePoints = coroutine.wrap(function() while wait(WaitTime) do if Player:GetRankInGroup(GroupId) >= MinRank then if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamePassx2Id) == true then Points.Value = Points.Value + (DefaultPoints*2) end if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamePassx5Id) == true then Points.Value = Points.Value + (DefaultPoints*5) end elseif MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamePassx2Id) and MarketplaceService:UserOwnsGamePassAsync(Player.UserId,GamePassx5Id) == true then Points.Value = Points.Value + 7 -- this means they stack instead of doing 2x5 = 10 (so if you have more multipliers then it doesn't get too many points) else Points.Value = Points.Value + DefaultPoints -- If the player don't own a gamepass they get normal point/s (1) end end end) UpdatePoints() Points.Changed:connect(function() pcall(function() PointsStore:SetAsync(Player.UserId, Points.Value) -- Saying when they change it should save points too just incase on removing the points don't save. end) end) end)