local ProfileService = require(game.ReplicatedStorage.ProfileService)
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("TimeStats")
local service = game:GetService("MarketplaceService")
local Profiles = {}
local GamepassId = 13914120
local saveStructure = {
Donated = 0;
Raised = 0;
}
local PlayerProfileStore = ProfileService.GetProfileStore("PlayerSaveData", saveStructure)
local function PlayerDataLoaded(player)
local profile = Profiles[player]
local folder = Instance.new("Folder")
folder.Name = "leaderstats"
folder.Parent = player
local Donated = Instance.new("IntValue")
Donated.Name = "Donated"
Donated.Value = profile.Data.Donated
Donated.Parent = folder
local Raised = Instance.new("IntValue")
Raised.Name = "Raised"
Raised.Value = profile.Data.Raised
Raised.Parent = folder
local Minutes = Instance.new("IntValue")
Minutes.Name = "Minutes"
Minutes.Value = 0
Minutes.Parent = folder
spawn(function()
local profile = Profiles[player]
if profile ~= nil then
Donated.Value = profile.Data.Donated
Raised.Value = profile.Data.Raised
end
end)
end
game.Players.PlayerAdded:Connect(function(Player)
local Minutes = Players.leaderstats.Minutes
local Data = DataStore:GetAsync(Player.UserId) -- Get Data
if type(Data) ~= "table" then
Data = nil
end
local incrementValue = 1 -- value when adding points
if (service:UserOwnsGamePassAsync(Player.UserId, GamepassId)) then -- 2x gamepass
incrementValue = 2
end
--[{ TIME GIVERS }]--
coroutine.resume(coroutine.create(function() -- gives 1 point every minute
while true do
wait(60) -- every minute
Minutes.Value = Minutes.Value + incrementValue -- adds points based off of the incrementValue
end
end))
end)
Hello, I am getting an error on line 52 local Minutes = Players.leaderstats.Minutes, why can I not call the leaderstats and get the minutes? How do I make the variable call it?
local ProfileService = require(game.ReplicatedStorage.ProfileService)
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("TimeStats")
local service = game:GetService("MarketplaceService")
local Profiles = {}
local GamepassId = 13914120
local saveStructure = {
Donated = 0;
Raised = 0;
}
local PlayerProfileStore = ProfileService.GetProfileStore("PlayerSaveData", saveStructure)
local function PlayerDataLoaded(player)
local profile = Profiles[player]
Profiles[player] = profile
local folder = Instance.new("Folder")
folder.Name = "leaderstats"
folder.Parent = player
local Donated = Instance.new("IntValue")
Donated.Name = "Donated"
Donated.Value = profile.Data.Donated
Donated.Parent = folder
local Raised = Instance.new("IntValue")
Raised.Name = "Raised"
Raised.Value = profile.Data.Raised
Raised.Parent = folder
local Minutes = Instance.new("IntValue")
Minutes.Name = "Minutes"
Minutes.Value = 0
Minutes.Parent = folder
spawn(function()
local profile = Profiles[player]
if profile ~= nil then
Donated.Value = profile.Data.Donated
Raised.Value = profile.Data.Raised
end
end)
end
game.Players.PlayerAdded:Connect(function(player)
local Minutes = player.leaderstats.Minutes
local Data = DataStore:GetAsync(player.UserId) -- Get Data
if type(Data) ~= "table" then
Data = nil
end
local incrementValue = 1 -- value when adding points
if service:UserOwnsGamePassAsync(player, GamepassId) then -- 2x gamepass
incrementValue = 2
end
--[{ TIME GIVERS }]--
coroutine.resume(coroutine.create(function() -- gives 1 point every minute
while true do
wait(60) -- every minute
Minutes.Value = Minutes.Value + incrementValue -- adds points based off of the incrementValue
end
end))
end)