First Problem is "Requested module experienced an error while loading"
local SkinModule = require(game.ServerScriptService:WaitForChild("ModuleScript"))
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if player.leaderstats.Cash.Value >= 500 then
local Skin = SkinModule.." selected"
game.ReplicatedStorage.OpenCrate:FireClient(player,Skin)
end
end)
Second is "ServerScriptService.Saves:5: attempt to index nil with 'Cash' "
local DS = game:GetService("DataStoreService"):GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plr = "id_"..plr.userId
local save1 = plr.leaderstats.Cash
local save2 = plr.leaderstat.BUX
local GetSaved = DS:GetAsync(plr)
if GetSaved then
save1.Value = GetSaved[1]
save2.Value = GetSaved[2]
else
local NumberForSaving = {save1.Value, save2.Value,}
DS:GetAsync(plr, NumberForSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
DS:SetAsync("id_"..plr.userId,{plr.leaderstats.Cash.Value, plr.leaderstats.BUX.Value,})
end)
Leaderstats script
local Cash = Instance.new("IntValue")
Cash.Value = 0
Cash.Name = 'Cash'
Cash.Parent = leaderstats
