Well this didn’t work out i tryed it yesterday, but my chrome got lagged so i couldn’t asnwer.
Which Tycoon Kit are you using?
It’s not tycoon kit, it’s an tutorial from a zero to a full working tycoon, also i fixed it. It was in case of dropper module. It should used as SetMoney function in player Manager not just add it to player balance. And now it works.
Hello I am also making tycoon game but my game has error to load player data when player play my game first time then he need to rejoin game and idk how to fix that
you can also check out my game and help me to fix it
Well i need a code atleast to fix it. Could you send me a message on DevForum?
Hmm wait well, it loads normally i think, and even of first time.
Edit: It working pretty good. That’s could be an roblox glitch.
code:
local DatastoreService = game:GetService(“DataStoreService”)
local Version = script.Parent.Parent:WaitForChild(“Datastorename”).Value
local MainData = DatastoreService:GetDataStore(“PlayerDatas”… Version)
local Datastore = {
Cache = {}
}
function Datastore:GetData(player)
local data = self.Cache[player]
local success, result = data, nil
local timeOut = 0
while not success do
success, result = pcall(MainData.GetAsync, MainData, player.UserId)
if success then
data = result
else
wait(0.5)
end
timeOut += 1
if timeOut > 5 then
return spawn(function()
player:Kick("Failed to load data; Please rejoin")
error(string.format("Data Getting Error: %s", result or ""))
end)
end
end
self.Cache[player] = data
return self.Cache[player]
end
function Datastore:SetData(player, data, remove)
local data = data or self.Cache[player]
local success, result = pcall(MainData.SetAsync, MainData, player.UserId, data)
local timeOut = 0
if not data then
return warn(player, "does not have data.")
end
while not success do
success, result = pcall(MainData.SetAsync, MainData, player.UserId, data)
wait(0.5)
timeOut += 1
if timeOut > 5 then
return spawn(function()
error(string.format("Data Saving Error: %s", result or ""))
end)
end
end
self.Cache[player] = not remove and data or nil
return self.Cache[player]
end
return Datastore
Well i don’t see any error in code and don’t see any error in game, it works pretty fine.
Hmmm could you show a warning which it gives, you just sent few errors to me which are not connected with datastore script. If you mean Datastore request is not a warn, it just in case you test this in studio. While you leave test it saves data of player and then again saves data in case server got closed and it makes studio lag a lot. To fix it there is one method, but i do not suggest it, in case it sometimes can break data save
Edit3: Also this won’t happen in game so it’s fine.
If you wanna more explain about this datastore error watch this video, he explains it here on a middle of video i think How to make a Tycoon in Roblox #8 - Saving Player Data [READ PINNED COMMENT] - YouTube
my game has http is off and now i turned on but it does not happened
can we play game at one after change datastore