#datastorage not functioning
1 messages · Page 1 of 1 (latest)
alr
local Players = game:GetService("Players")
local playerDataStore = DataStoreService:GetDataStore("XPLevelData")
Players.PlayerAdded:Connect(function(player)
-- Setup leaderstats
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local XP = Instance.new("IntValue")
XP.Name = "XP"
XP.Value = 0
XP.Parent = leaderstats
local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Value = 1
Level.Parent = leaderstats
-- Load saved data
local success, data = pcall(function()
return playerDataStore:GetAsync(player.UserId)
end)
if success and data then
XP.Value = data.XP or 0
Level.Value = data.Level or 1
print("Loaded data for", player.Name, "| XP:", XP.Value, "| Level:", Level.Value)
else
if not success then
warn("Error loading data for", player.Name)
else
print("No saved data found for", player.Name)
end
end
end)
Players.PlayerRemoving:Connect(function(player)
local success, err = pcall(function()
playerDataStore:SetAsync(player.UserId, {
XP = player.leaderstats.XP.Value,
Level = player.leaderstats.Level.Value
})
end)
if success then
print("✅ Saved data for", player.Name, "| XP:", player.leaderstats.XP.Value, "| Level:", player.leaderstats.Level.Value)
else
warn("❌ Failed to save player data for", player.Name, ":", err)
end
end)
i used chatgpt to help me but yeah didnt work
i got API enabled n etc
any erros?
none..
after getting level 2
and i rejoin i get sent back to level 1
both on studio and on roblox
lemme see
Ill just tell you whats wrong
okk
just use indexes for loading and saving instead of data.XP and data.Level
wait
lemme look up if that makes a difference, not sure
im new to scripting as well.. so idk how that works..
and do you feel like joining my project? 😭
i aint that good at scripting man
500rs?
wait what game even is this
dark fantasy type of game
i already have a "zone" ish area
so once u enter like a dark area it becomes mystic and dark
and i have the stamina, health, and xp bar done
which works
as well as a keybinds ig? for mute, settings etc
is this your first project tho?
no
ive made multiple
this time i want to make a somewhat small project or a actual game
and if it goes somewhat successful i will focus on it
i already got like 1k visits on a old game from 2019
no scripting nothing, just simple toolbox items
and dark fantasy is kind of a trend on tt rn
are you using toolbox items for this one?
only the animals and maybe trees for XP
well then no
free models are so dangerous bruh
if it gets 5-10+ active players or so then ofc i will invest more and get actual modelers/builders
no it didnt print anything
ah f
what is it saying
i ended up deleting the orginal playerdatasave script
and made a new one
and it ended up printing
i used indexes
local DataStoreService = game:GetService("DataStoreService")
local playerDataStore = DataStoreService:GetDataStore("XPLevelData")
-- === Load Data on Player Join
Players.PlayerAdded:Connect(function(player)
-- Setup Attributes (safe defaults)
player:SetAttribute("XP", 0)
player:SetAttribute("Level", 1)
-- Try to load data
local success, data = pcall(function()
return playerDataStore:GetAsync(player.UserId)
end)
if success and data then
print(":white_check_mark: Loaded data for", player.Name, data)
player:SetAttribute("XP", data["XP"] or 0)
player:SetAttribute("Level", data["Level"] or 1)
else
if not success then
warn(":x: Failed to load data for", player.Name)
else
print(":detective: No saved data found for", player.Name)
end
end
end)
-- === Save Data on Player Leave
Players.PlayerRemoving:Connect(function(player)
local data = {
["XP"] = player:GetAttribute("XP"),
["Level"] = player:GetAttribute("Level")
}
local success, err = pcall(function()
playerDataStore:SetAsync(player.UserId, data)
end)
if success then
print(":floppy_disk: Saved data for", player.Name, data)
else
warn(":x: Failed to save data for", player.Name, err)
end
end)
-- === Save Data on Server Shutdown
game:BindToClose(function()
for _, player in ipairs(Players:GetPlayers()) do
local data = {
["XP"] = player:GetAttribute("XP"),
["Level"] = player:GetAttribute("Level")
}
local success, err = pcall(function()
playerDataStore:SetAsync(player.UserId, data)
end)
if success then
print(":floppy_disk: (Shutdown) Saved data for", player.Name, data)
else
warn(":x: (Shutdown) Failed to save", player.Name, err)
end
end
end)
look for errors, and chatgpt forgot to add game:bindtoclose. classic chatgpt
also did the old script print anything?
for my XP i believe
** You are now Level 6! **
lol chatgpt added it on the second try 
are you sure
ye
you checked all the boxes
because here it says there are 5 in log
my bad
i joined the game with level 1, and i got to level2, and left
its supposed to save automatically no?
what did it print after you left with level 2
is this your game?
let me see
yes
how are you adding levels and xp?
after leaving with levle2
i'd wager you're doing player:AddXP() on the client
welp
your changing data on the client
most likely
ye looks like you're adding levels/xp on the client
that screenshot says it all
which the server doesnt know about
believe it or not this chatgpt actually is somewhat accurate, it made me a somewhat of a decent advanced system and more which a typical normal chatgpt doesnt
oh
which didn't work 
for this yes
I was about to say
how can i resolve this..
ask the guy who wrote the code 
first rule in testing data saving, dont change data in client
use a remote event to send a message to change data on the server
or re-write the system
knowing the problem is one thing, fixing it is a whole different problem, specially in cases like this 
yeah anywhere that works with levels/xp needs to be reworked
playerdatasave?
huh?
the script
oh wait
i have my XP/leveling on
local script
so i should make it local ye?
thats literally what we said
script*
not to make it local
yeah script **
frankly if you don't do it properly you're opening your game wide to exploiters. lol remoteevent.OnServerEvent:Connect(function(plr,item,cost) plr.Money-=cost plr:GiveItem(item) end) 
yea people gonna be getting to endgame instantly
dont believe people would want to cheat in a unknown game, but if it do get succesful somehow i will invest robux and make it better
no endgame honestly
open world game
bruh my game has less than 1k visitors and my automatic anti-skid system autobanned an exploiter.
less than 1k visits, already first exploiter, and that's only the one that was caught
there will eventually be a end but not yet
well when there is one then someone will cheat to the end asap
that's a 100% guaranteed confirmed exploiter btw, there ain't no false positives with the way that skid got banned 
then he aint gonna get the experience of the game so idc abt him
so yeah, believe it or not
other players will 😂
** You are now Level 17! **
the whole point is to go through a adventure, defeat bosses, side quests, so if he goes to end then no point?
ruins it for others
people leave because of it
dead game
how abt i worry about that once i receive like 5+ daily active players or so?
right now its a small project/test
smooth brain approach but hey, ngl, if you'd rather prioritize the actual gameplay than correcting for exploiters, honestly if your game does any decently you can probably just hire a scripter later on to seek, locate, and squash and exploitability in your code 
if it goes somewhat decent i will invest for scripters
great idea, now you have to add a new system super quickly when the game gets some players
that's a good approach 💯
and by that point it will be too late
fun fact: it wont go decent without scripters
eh you never know
again i will hire scripters once i see some action going on
I guess
if i hire rn, it can be a waste or success
or just like find willing people and give revenue share
u want %?
nope
exactly nobody wants %
A. I already lead a team
B. You gave me a bad impression as a planner
?? this isnt my final game dude
im literally trying and testing
and if my test goes good i will invest
I know
u want me to add super high end anticheat for my test game?
yes but your plan for the game kinda is not the best
it is a very fair idea to prioritize developing the actual game first. anticheat can come in at a close second. it's not uncommon for brand new games to completely reset player data (with consideration given to player robux purchases) so i mean if you state that somewhere people won't mind the exploiters until the game has an opportunity to first have that as a problem it needs to care about and then second have a chance to do something about it
so actually it's a better plan than most other people have who trap themselves in analysis paralysis trying to figure out how to make the game they want to make while also accounting for exploiters at the same time. nah, game first bruh.
odds of them even cheating at a unknown game is really low imo
but again even if cheaters ruin my game
it will ruin for a couple people
honestly just do what you think is best
by that time i can hire scripers
so again about the uhm local script, how do i change it to a script?
trial and error is best
probably best to rewrite some of the XP system considering you have it changing on the client
practice makes perfect
follow the fun
yup
this is my uhh Xphandler is this the one?
although i have high hopes it will succeed
it has userinputservice which is clientside only, so yeah that's a script you'll probably need to change, particularly since it has this function in it:
-- === Award XP Function
local function awardXP(amount)```
awardXP should usually happen on server not client
ah
guess chatgpt thought it was gonna be single player game
do i ask it to rewrite the local into a script, that isnt single player but rather multi or?
it did sound like a singleplayer game. pick your priorities i guess. i think you're right to follow the fun and simply make a working game first, you can worry about this later
the brain capacity of my 2 braincells is too much to handle here
it was meant for a multiplayer game
like survival,open world etc
But I do have a tip in case your not doing so already: Learn a skill or 2 (Scripting, Builder, Gfx, Vfx, music, etc.) and practice practice practice. Dont overwhelm yourself learning a whole bunch of stuff all at once especially as a new aspiring dev
any chance i could hire you if this goes well? and how much would it cost?
I tried that once, burnout in the first 2 weeks
i mainly focus on building
to master a language can take a year or more
smth i dont plan on doing tbh
also if you have the option, find a friend that wants to make games so that you can help each other figure things out. The more the better
its always much more fun working with someone else
but its your choice still
i would need to see more than a fantasy game wishlist and ai code to agree to anything you can even theoretically afford
meaning
i don't care much for builders since i can build myself, you'd have to have a very dashing portfolio that competes with other builders in #👷︱for-hire in your price range. if you had related building skills like modelling, texturing, csg, or non-humanoid animation, maybe i'd have work for you, but.. yea building can mean a lot of different things.
if your best work is a gas station, that isn't good enough for what i'm looking for
it's good, but i need more than a few days of tedium putting together a storefront
Welp ima head out, good luck on your journey
no its not a gas station xd
but uhm i believe we are on wrong track, so could u help me out w the script?..
didn't we already do that?
so i gotta redo everything?..
i mean let's be honest here you know nothing about coding, ai is doing all the heavy lifiting, so even if i told you how to solve it, you wouldn't even know where to start. chatgpt is doing it for you. that's why i say maybe try asking the person who wrote this code for you
we helped you with the problem, but if we just simply do it for you, that's not help anymore, that's just free labor 
thought u were being sarcastic w the ask the person who wrote it..
half and half
not sarcastic in the sense that if you don't know how to code and don't want to learn, then go back to the ai with knowing what the problem is, or hire someone 👍
alright thanks for letting me know