game.Players.PlayerAdded:connect(function(player) local PlayerStorege = player:WaitForChild("PlayerStorege") local RemoteSAVE = PlayerStorege:WaitForChild("RemoteSAVE") local RemoteLOAD = PlayerStorege:WaitForChild("RemoteLOAD") local Cash = player.PlayerStats:WaitForChild("Cash") wait(5) Cash.Value = PlayerCashDataStore:GetAsync(player.UserId) or 0 if PlayerCashDataStore:GetAsync(player.UserId) == 0 then Cash.Value = 100 PlayerCashDataStore:SetAsync(player.UserId, Cash.Value) else end
ERROR Unable to cast value to function
local DataStore = game:GetService("DataStoreService") local PlayerCashDataStore = DataStore:GetDataStore("PlayerCashDataStoreeee") game.Players.PlayerAdded:connect(function(player) local PlayerStorege = player:WaitForChild("PlayerStorege") local RemoteSAVE = PlayerStorege:WaitForChild("RemoteSAVE") local RemoteLOAD = PlayerStorege:WaitForChild("RemoteLOAD") local Cash = player.PlayerStats:WaitForChild("Cash") wait(5) Cash.Value = PlayerCashDataStore:GetAsync(player.UserId) or 0 if PlayerCashDataStore:GetAsync(player.UserId) == 0 then Cash.Value = 100 PlayerCashDataStore:SetAsync(player.UserId, Cash.Value) else end RemoteSAVE.OnServerEvent:connect(function(player) print("Saving Data for player " .. player.Name .. " of "..Cash.Value) PlayerCashDataStore:UpdateAsync(player.UserId, Cash.Value) end) RemoteLOAD.OnServerEvent:connect(function(player) Cash.Value = PlayerCashDataStore:GetAsync(player.UserId) end) RemoteLOAD.OnServerEvent:connect(function(player) wait(1) local PlayerGui = player:WaitForChild("PlayerGui") local CashDisplay = PlayerGui:WaitForChild("CashDisplay") local CashFrame = CashDisplay:WaitForChild("CashFrame") local CashGui = CashFrame:WaitForChild("Cash") CashGui.Text = "$".. Cash.Value end) end)