local Players = game:GetService(“Players”)
local ServerScriptService = game:GetService(“ServerScriptService”)
local Template = require(ServerScriptService.PlayerData.Template)
local Manager = require(ServerScriptService.PlayerData.Manager)
local ProfileService = require(ServerScriptService.Libs.ProfileService)
local ProfileStore = ProfileService.GetProfileStore(“2”, Template) – (1 = Test) (2 = Production)
local KICK_MESSAGE = “Could not find data Please rejoin If issue persists, contact us via group wall”
local function CreateLeaderStats(player: Player)
local profile = Manager.Profiles[player]
if not profile then return end
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local coins = Instance.new("NumberValue", leaderstats)
coins.Name = "Clicks"
coins.Value = profile.Data.Clicks
local Gems = Instance.new("NumberValue", leaderstats)
Gems.Name = "Gems"
Gems.Value = profile.Data.Gems
end
local function LoadProfile(player: Player)
local profile = ProfileStore:LoadProfileAsync(“Player_”…player.UserId)
if not profile then
Players:Kick(KICK_MESSAGE)
return
end
profile:AddUserId(player.UserId)
profile:Reconcile()
profile:ListenToRelease(function()
Manager.Profiles[player] = nil
Players:Kick(KICK_MESSAGE)
end)
if player:IsDescendantOf(Players) == true then
Manager.Profiles[player] = profile
CreateLeaderStats(player)
else
profile:Release()
end
end
for _, Player in Players:GetPlayers() do
task.spawn(LoadProfile, Players)
end
Players.PlayerAdded:Connect(LoadProfile)
Players.PlayerRemoving:Connect(function(Players)
local profile = Manager.Profiles[Players]
if profile then
profile:Release()
end
end)
type checking has nothing to do with the error, it will just signal the compiler or the IDE that it will probably be that variable, but not error (unless its on strict mode).
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local Template = require(ServerScriptService.PlayerData.Template)
local Manager = require(ServerScriptService.PlayerData.Manager)
local ProfileService = require(ServerScriptService.Libs.ProfileService)
local ProfileStore = ProfileService.GetProfileStore("2", Template) -- (1 = Test) (2 = Production)
local KICK_MESSAGE = "Could not find data, please rejoin. If issue persists, contact us via group wall"
local function CreateLeaderStats(player: Player)
local profile = Manager.Profiles[player]
if not profile then return end
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
local coins = Instance.new("NumberValue", leaderstats)
coins.Name = "Clicks"
coins.Value = profile.Data.Clicks
local Gems = Instance.new("NumberValue", leaderstats)
Gems.Name = "Gems"
Gems.Value = profile.Data.Gems
leaderstats.Parent = player
end
local function LoadProfile(player: Player)
local profile = ProfileStore:LoadProfileAsync("Player_"..player.UserId)
if not profile then
Players:Kick(KICK_MESSAGE)
return
end
profile:AddUserId(player.UserId)
profile:Reconcile()
profile:ListenToRelease(function()
Manager.Profiles[player] = nil
Players:Kick(KICK_MESSAGE)
end)
if player:IsDescendantOf(Players) == true then
Manager.Profiles[player] = profile
CreateLeaderStats(player)
else
profile:Release()
end
end
for _, Player in Players:GetPlayers() do
task.spawn(LoadProfile, Players)
end
Players.PlayerAdded:Connect(LoadProfile)
Players.PlayerRemoving:Connect(function(Players)
local profile = Manager.Profiles[Players]
if profile then
profile:Release()
end
end)
Script 3 - Data
local Players = game:GetService(“Players”)
local ServerScriptService = game:GetService(“ServerScriptService”)
local Template = require(ServerScriptService.PlayerData.Template)
local Manager = require(ServerScriptService.PlayerData.Manager)
local ProfileService = require(ServerScriptService.Libs.ProfileService)
local KICK_MESSAGE = "Could not find data Please rejoin If issue persists, contact us via group wall”
local function CreateLeaderStats(player: Player)
local profile = Manager.Profiles[player]
if not profile then return end
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local coins = Instance.new("NumberValue", leaderstats)
coins.Name = "Clicks"
coins.Value = profile.Data.Clicks
local Gems = Instance.new("NumberValue", leaderstats)
Gems.Name = "Gems"
Gems.Value = profile.Data.Gems
end
local function LoadProfile(player: Player)
local profile = ProfileStore:LoadProfileAsync(“Player_”…player.UserId)
if not profile then
Players:Kick(KICK_MESSAGE)
return
end
profile:AddUserId(player.UserId)
profile:Reconcile()
profile:ListenToRelease(function()
Manager.Profiles[player] = nil
Players:Kick(KICK_MESSAGE)
end)
if player:IsDescendantOf(Players) == true then
Manager.Profiles[player] = profile
CreateLeaderStats(player)
else
profile:Release()
end
end
for _, Player in Players:GetPlayers() do
task.spawn(LoadProfile, Players)
end
Players.PlayerAdded:Connect(LoadProfile)
Players.PlayerRemoving:Connect(function(Players)
local profile = Manager.Profiles[Players]
if profile then
profile:Release()
end
end)