its just speaking about the module script
local Data,Error = pcall(function()
ds:GetAsync(plrkey)
end)
if Data Then
print("DataLoaded")
save1.Value = GetSaved[1]
save2.Value = GetSaved[2]
else
print(Error)
end
There is a typo in the SetAsync, itās leaderstat
yes, i just realised that got distracted by the getasync
No, just keep your original script, changed the plrkey to local plrkey = plr.UserId
and in the playerremoving you misspelled leaderstats
oh ok ill try that out
123131231231231
it says this i think i should remove the dot ?
and i chanded the plr.userid back to plrkey and it just stil wouldent work
another issue that poped up was that when another player is playing the game they can only see there points going up and not the other persons i think i might have to do with like updating the leaderstats
well thats really really weirdā¦
ikr ive never got this much of a problem in my codes
it could possibly be another one of your codes
ye thats what i was thinking or it might be like a virus
idk tbh
Try this:
local dds = game:GetService("DataStoreService")
local saveData = dds:GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(plr)
local data
local lds = plr.leaderstats
local success, failed = pcall(function()
data = saveData:GetAsync(plr.UserId) or {}
end)
if success then
lds.save1.Value = data[1]
lds.save2.Value = data[2]
else
warn(failed)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local lds = plr.leaderstats
saveData:SetAsync("id_"..plr.UserId, lds.Clicks.Value, lds.Rebirths.Value)
end)
game:BindToClose(function()
local players = game:GetService("Players")
for _, plr in pairs(players:GetPlayers()) do
local lds = plr.leaderstats
local success, failed = pcall(function()
saveData:SetAsync("id_"..plr.UserId, lds.Clicks.Value, lds.Rebirths.Value)
end)
if not success then
warn(failed)
end
end
end)
Edit: made an edit to the code x3
alr ill try it on its own thanks
when you tried mine, did you put it in just the leaderstats? and have only the leaderstats? (and other scripts youll need)
ye i made like a seperate one and only used the one script
Hello, you should use pcall()
for DataStore:SetAsync()
and DataStore:GetAsync()
.
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("SaveData")
local function LoadPlayerData(Player)
local Data
pcall(function()
Data = DataStore:GetAsync(Player.UserId)
end)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
local Clicks = Instance.new("NumberValue")
Clicks.Name = "Clicks"
local Rebirths = Instance.new("NumberValue")
Rebirths.Name = "Rebirths"
if Data then
Clicks.Value = Data.Clicks
Rebirths.Value = Data.Rebirths
end
Clicks.Parent = leaderstats
Rebirths.Parent = leaderstats
leaderstats.Parent = Player
end
local function SavePlayerData(Player)
local leaderstats = Player:FindFirstChild("leaderstats")
if leaderstats then
local DataToSave = {}
DataToSave.Clicks = leaderstats.Clicks.Value
DataToSave.Rebirths = leaderstats.Rebirths.Value
pcall(function()
DataStore:SetAsync(Player.UserId, DataToSave)
end)
end
end
Players.PlayerAdded:Connect(LoadPlayerData)
Players.PlayerRemoving:Connect(SavePlayerData)
game:BindToClose(function()
wait(1)
end)
hmmm, i dont know lolā¦
above us you said āidk if it might be bc of the way the clicks button is coded it also has a effect that pops upā what is the script for thaT?
me and my friend have the same thing probably on our game⦠but we have no problems with it⦠but we only have clicks.
ye i have like a coded this that showes u a effect every time u click its like a emoji pops up
ok im trying that other script Doqee one didnt work