Hi, I have a question about this script, I watched this from a tutorial somewhere but it doesn’t work. What is wrong with this and what can I change? Thank you in advance! This is my code:
local DSS = game:GetService("DataStoreService")
local MyData = DSS:GetDataStore("MyDataStore")
game.Players.PlayerAdded:Connect(function(plr)
local LS = Instance.new("Folder")
LS.Name = "leaderstats"
LS.Parent = plr
local Money = Instance.new("IntValue")
Money.Name = "Money"
Money.Parent = LS
local data
local success, errormessage = pcall(function()
data = MyData:GetAsync(plr.UserId.."-money")
end)
if success then
Money.Value = data
else
print("There is a error")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local success, errormessage = pcall(function()
MyData:GetAsync(plr.UserId.."-money", plr.leaderstats.Money.Value)
end)
if success then
print("The data will be stored for "..plr.Name)
else
print("Something went wrong while saving ".. plr.Name.. "'s data")
warn(errormessage)
end
end)
I give myself money through a party and then I rejoin and then it’s 0 again