local FirstTime = {} game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) if FirstTime[Player.UserId] == nil then FirstTime[Player.UserId] = true Player.Character.Humanoid.Health = 0 end end) end) game.Players.PlayerAdded:Connect(function(Player) FirstTime[Player.UserId] = nil end)
this code basically sets the players health to 0 but for some reason humanoid does not die and health goes up.
You should use:
repeat task.wait() until plr.Character -- plr is the player instance value
To check if 'Character' is a children of Player.
Also if you want to check if the player just joined, instead of using a dictionary/array, you can give the player a BoolValue.
To use it like this.
local FirstTime = {} game.Players.PlayerAdded:Connect(function(Player) local folder = Instance.new('Folder') folder.Parent = Player folder.Name = 'PlrValues' -- you can change this to whatever you want. local FirstTime = Instance.new('BoolValue') FirstTime.Parent = folder FirstTime.Name = 'FirstTimeBool' -- you can change this to whatever you want too. FirstTime.Value = false Player.CharacterAdded:Connect(function(Character) repeat task.wait() until plr.Character if FirstTime.Value == false then FirstTime.Value = true Player.Character.Humanoid.Health = 0 end end) end)
You will not need the event PlayerRemoving, because if the player joins again the server, the value 'FirstTImeBool' will be false(Unless you save it in a datastore).
Hope this helped :)