I see 2 errors in your script.
1st one:
if script.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0 then
Player.Objects.Value == 0
end
You used = when CHECKING if the player's health is 0 and == when SETTING the value of Objects to 0.
= is used to SET a value and == is used to CHECK if a value is equal to another value.
2nd one:
Don't use LocalScripts to save things. Use a Script in ServerScriptStorage instead:
local DataStoreService = game:GetService('DataStoreService')
local DataStore = DataStoreService:GetDataStore('SaveSystem')
while wait(1) do
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new('Folder', player)
leaderstats.Name = "leaderstats"
local Objects = Instance.new("IntValue", leaderstats)
Objects.Value = DataStore:GetAsync(player.UserId) or 0
DataStore:SetAsync(player.UserId, money.Value)
Objects.Changed:Connect(function()
DataStore:SetAsync(player.UserId, Objects.Value)
end)
end)
if player.Character.Humanoid.Health == 0 then
Objects.Value = 0
end
end
1 comment
You're using the assigned to operator. Use the assignment operator (=)