My code
local Players = game:GetService("Players")
local cachedProfiles = {}
local ProfileService = require(script.ProfileService)
local saveStructure = {
coins = 0;
Clown = 0;
Default = 0;
ROBLOX = 0;
Seer = 0;
SkillPointsLeft = 0;
}
local PlayerProfileStore = ProfileService.GetProfileStore("PlayerSaveData", saveStructure)
local function PlayerDataLoaded(player)
print("loaded")
local profile = cachedProfiles[player]
local folderStats = player:WaitForChild("stats")
local KnivesFolder = Instance.new("Folder", player)
KnivesFolder.Name = "Knifes"
local Clown = Instance.new("IntValue")
Clown.Name = "Clown"
Clown.Value = profile.Data.Clown
Clown.Parent = KnivesFolder
local ROBLOX = Instance.new("IntValue")
ROBLOX.Name = "ROBLOX"
ROBLOX.Value = profile.Data.ROBLOX
ROBLOX.Parent = KnivesFolder
local Seer = Instance.new("IntValue")
Seer.Name = "Seer"
Seer.Value = profile.Data.Seer
Seer.Parent = KnivesFolder
repeat wait() until player:WaitForChild("stats"):WaitForChild("coins")
local coins = Instance.new("IntValue")
coins.Name = "coins"
coins.Value = profile.Data.coins
coins.Parent = folderStats
local SkillPointsLeft = Instance.new("IntValue")
SkillPointsLeft.Name = "SkillPointsLeft"
SkillPointsLeft.Value = profile.Data.SkillPointsLeft
SkillPointsLeft.Parent = folderStats
--[[Ex.
local Clown = Instance.new("IntValue")
Clown.Name = "Clown"
Clown.Value = profile.Data.Clown
Clown.Parent = folderStats
]]
spawn(function()
while true do
local profile = cachedProfiles[player]
if profile ~= nil then
Clown.Value = profile.Data.Clown
ROBLOX.Value = profile.Data.ROBLOX
Seer.Value = profile.Data.Seer
coins.Value = profile.Data.coins
SkillPointsLeft.Value = profile.Data.SkillPointsLeft
else
break
end
wait(0.1)
end
end)
print(player.Name .. "'s data is loaded")
end
local function PlayerAdded(player)
local profile = PlayerProfileStore:LoadProfileAsync("Player_" .. player.UserId, "ForceLoad")
if profile ~= nil then
profile:ListenToRelease(function()
cachedProfiles[player] = nil
player:Kick("Your profile has been loaded remotely. Please rejoin.")
end)
if player:IsDescendantOf(Players) then
cachedProfiles[player] = profile
PlayerDataLoaded(player)
else
profile:Release()
end
else
player:Kick("Unable to load saved data. Please rejoin.")
end
end
for _, player in ipairs(Players:GetPlayers()) do
spawn(function()
PlayerAdded(player)
end)
end
Players.PlayerAdded:Connect(PlayerAdded)
Players.PlayerRemoving:Connect(function(player)
local profile = cachedProfiles[player]
if profile ~= nil then
profile:Release()
end
end)
return cachedProfiles
Profile Service: https://raw.githubusercontent.com/MadStudioRoblox/ProfileService/master/ProfileService.lua
There are no prints or anything, both scripts are in module scripts.
It kicks one random player from the game saying datastore issue, any idea why?