Hi I have been trying to script a game and I got help with this script, but it only works in a test server with one player. It doesn't work on a server with 2 or more players. Can you help?
humanoid = game.Players.LocalPlayer.Character.Humanoid function round1Place(x) return (x + 0.05 - (x + 0.05) % .1) end while wait() do script.Parent.Text = "You have " .. round1Place(humanoid.Health) .. " health left" end
repeat wait() until game.Players.LocalPlayer.Character -- The Character loads a little while after the Player, so this will be nil. To change that, we add this. This keeps waiting until a Character is detected. humanoid = game.Players.LocalPlayer.Character.Humanoid function round1Place(x) return (x + 0.05 - (x + 0.05) % .1) end while wait() do script.Parent.Text = "You have " .. round1Place(humanoid.Health) .. " health left" end
--I have added an event so that multiple people could be seen working with the humanoids health game.Players.PlayerAdded:connect(function(player) humanoid =player.Character.Humanoid function round1Place(x) return (x + 0.05 - (x + 0.05) % .1) end while wait() do script.Parent.Text = "You have " .. round1Place(humanoid.Health) .. " health left" end --If this helped don't forget to leave a upvote or an accept.