Im trying to create a script that changes the value on death. Please Help.
game:GetService('Players').PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
player = game.Players:GetPlayerFromCharacter(character)
if player:FindFirstChild("InGame") then
player.InGame:remove()
character:WaitForChild("Humanoid").Died:connect(function()
print(player.Name .. " has died!")
game.Workspace.PeopleInGame.Value = game.Workspace.PeopleInGame.Value -1
end)
end
end)
end)
Output: 22:11:19.638 - Workspace.PlayerHandler:8: attempt to perform arithmetic on field 'PeopleInGame' (a userdata value)

3 comments
Add .Value to the second PeopleInGame Value. Instead the script is reading it like number = object - 1
It still isnt working
Get rid of line 3, It's not needed.