HELP its been about a month my game is delayed cuz the datastore error
Can somebody fix my code to work, im trying to make a DataStore for Cash
link to repost: https://scriptinghelpers.org/questions/107002/data-store-error-plz-help-repost
Output: DS isn't a vaild part of DataModel
Thanks to anybody who fixes it!
local DS = game:GetService("DataStoreService")
local CurrencySave = game.DS:GetService("FirstStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cash = Instance.new("IntValue", leaderstats)
cash.Name = "Fruit"
cash.Value = 100
local data
local success, errormessage = pcall(function(player)
data:GetAsync(player.UserId.."-cash")
end)
if success then
cash.Value = data
else
print("There was an error while getting your data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall (function()
CurrencySave:SetAsync(player.UserId.."-cash", player.leaderstats.Fruit.Value)
end)
if success then
print("Player data Saved!")
else
print("Player Data didn't Save.")
warn(errormessage)
end
end)

7 comments
Yes, make sure to put it in "ServerScriptService too".
DesertusX, Heres the error in the output "DS is not a vaild member of DataModel."
Sorry! It should work now!
you DestusX lemme hit you up on roblox and add you to team Create
im jack90078
Sure!
add me back