game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
print(player.Name .. " has died!")
local Life = player:WaitForChild("Life").Value
Life = Life - 1
end)
end)
end)
Properties in roblox lua are passed by value, not passed by reference.
It means, that variable Life and player:WaitForChild(“Life”).Value, will be stored in different memory addresses. Life will copy the value of player:WaitForChild(“Life”).Value, not point to it.
Then, change it back and print the value before and after it is set to 0.
Also, even though there is a low possibility of that, but are you sure that the instance in the explorer is an intValue? They all look the same, so you might have confused them.
Then, I don’t know why that’s happening. If it worked for the player:WaitForChild(“Life”).Value, then it should work all the time. I will look into that tomorrow, and reply if I find the solution.