Hey there, so apparently in my friends game (I'm the scripter) people are getting minutes even out of game. Here is my minutes giving code :
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = plr:WaitForChild("leaderstats")
local Minutes = leaderstats:WaitForChild("Minutes")
while wait(60) do
Minutes.Value += 1
if not plr then break end
end
end)
I don't know what's wrong but I use a module for making leaderstats (I made it) Here is the modules code :
local module = {}
function module:CreateLeaderstatsForPlayer(Player: Player, Data: {})
local Leaderstats = Instance.new("Folder")
Leaderstats.Name = "leaderstats"
Leaderstats.Parent = Player
for index, value in pairs(Data) do
local Name = value.Name
local ClassName = value.ClassName
if not Name then return warn("No Name was provided.") end
if not ClassName then return warn("No ClassName was provided.") end
if not string.find(ClassName, "Value") then return warn("Invalid ClassName.") end
if not (pcall(function() Instance.new(ClassName):Destroy() end)) then
return warn("ClassName "..ClassName.."does not exist.")
end
local Stat = Instance.new(ClassName)
Stat.Name = Name
Stat.Parent = Leaderstats
Stat.Value = 0 or nil
end
return Leaderstats
end
function module:CreateLeaderstatsOnPlayerJoin(Data: {})
local Players = game:GetService("Players")
return Players.PlayerAdded:Connect(function(Player)
local Leaderstats = Instance.new("Folder")
Leaderstats.Name = "leaderstats"
Leaderstats.Parent = Player
for index, value in pairs(Data) do
local Name = value.Name
local ClassName = value.ClassName
if not Name then return warn("No Name was provided.") end
if not ClassName then return warn("No ClassName was provided.") end
if not string.find(ClassName, "Value") then return warn("Invalid ClassName.") end
if not (pcall(function() Instance.new(ClassName):Destroy() end)) then
return warn("ClassName "..ClassName.."does not exist.")
end
local Stat = Instance.new(ClassName)
Stat.Name = Name
Stat.Parent = Leaderstats
Stat.Value = 0 or nil
end
end)
end
return module
I use the first function module:CreateLeaderstatsForPlayer(plr, {data here}) in another script.
So can anyone help me here?

1 comment
Turns out it was the module script.