i tried making my script into a data store but then it says on line 50 '<eof>' expected near 'end'
how do i fix this?
local data = game:GetService("DataStoreService") local mineminemine = data:GetDataStore("mineminemine") game.Players.PlayerAdded:Connect(function(player) local stats = Instance.new("Folder",player) stats.Name = "leaderstats" local cash = Instance.new("IntValue",stats) cash.Name = "Cash" cash.Value = 10 local gold = Instance.new("IntValue",stats) gold.Name = "Gold" gold.Value = 0 local data local succes, errormessage = pcall(function() data = mineminemine:SetAsync(player.UserId.."-cash") end) if succes then cash.Value = data else print("aww not loaded") warn(errormessage) end end) game.Players.PlayerRemoving:Connect(function(player) local succes, errormessage = pcall(function() mineminemine:SetAsync(player.UserId.."-cash",player.leaderstats.Cash.Value and player.leaderstats.Gold.Value) end) if succes then print("YES") else print("aww not save") warn(errormessage) end end) cash.Changed:Connect(function() if player.leaderstats.Cash.Value >= 10000 then player.leaderstats.Cash.Value = 0 -- Set the value = 0 player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 1 end end) end)
You need to put your cash.Changed function inside player added and you needed to remove an end after this if statement:
if succes then print("YES") else print("aww not save") warn(errormessage) end
entire script:
local data = game:GetService("DataStoreService") local mineminemine = data:GetDataStore("mineminemine") game.Players.PlayerAdded:Connect(function(player) local stats = Instance.new("Folder",player) stats.Name = "leaderstats" local cash = Instance.new("IntValue",stats) cash.Name = "Cash" cash.Value = 10 local gold = Instance.new("IntValue",stats) gold.Name = "Gold" gold.Value = 0 local data local succes, errormessage = pcall(function() data = mineminemine:SetAsync(player.UserId.."-cash") end) if succes then cash.Value = data else print("aww not loaded") warn(errormessage) end cash.Changed:Connect(function() if player.leaderstats.Cash.Value >= 10000 then player.leaderstats.Cash.Value = 0 -- Set the value = 0 player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 1 end end) end) game.Players.PlayerRemoving:Connect(function(player) local succes, errormessage = pcall(function() mineminemine:SetAsync(player.UserId.."-cash",player.leaderstats.Cash.Value and player.leaderstats.Gold.Value) end) if succes then print("YES") else print("aww not save :( ") if(errormessage)then warn(errormessage) end end end)