player = game.Players.LocalPlayer system = game.workspace.system function onDeath() system.playersalive.Value = system.playersalive.Value -1 player.CameraMode="Classic" system.joindeadmsg.Value = player.Name .. " has died." end player.Character.Humanoid.Died:connect(onDeath)
OUTPUT:
14:46:41.106 - Players.Player1.PlayerGui.maingui.ondead:10: attempt to index field 'Character' (a nil value)
14:46:41.106 - Stack Begin
14:46:41.107 - Script 'Players.Player1.PlayerGui.maingui.ondead', Line 10
14:46:41.108 - Stack End
Use the :WaitForChild()
event
Example
local Player = game.Players.LocalPlayer local Character = Player:WaitForChild("Character")
player = game.Players.LocalPlayer player.CharacterAdded:wait() system = game.workspace.system function onDeath() system.playersalive.Value = system.playersalive.Value -1 player.CameraMode="Classic" system.joindeadmsg.Value = player.Name .. " has died." end player.Character.Humanoid.Died:connect(onDeath)