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?
1 | humanoid = game.Players.LocalPlayer.Character.Humanoid |
2 | function round 1 Place(x) |
3 | return (x + 0.05 - (x + 0.05 ) % . 1 ) |
4 | end |
5 |
6 | while wait() do |
7 | script.Parent.Text = "You have " .. round 1 Place(humanoid.Health) .. " health left" |
8 | end |
1 | 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. |
2 | humanoid = game.Players.LocalPlayer.Character.Humanoid |
3 | function round 1 Place(x) |
4 | return (x + 0.05 - (x + 0.05 ) % . 1 ) |
5 | end |
6 |
7 | while wait() do |
8 | script.Parent.Text = "You have " .. round 1 Place(humanoid.Health) .. " health left" |
9 | end |
01 | --I have added an event so that multiple people could be seen working with the humanoids health |
02 | game.Players.PlayerAdded:connect( function (player) |
03 | humanoid = player.Character.Humanoid |
04 | function round 1 Place(x) |
05 | return (x + 0.05 - (x + 0.05 ) % . 1 ) |
06 | end |
07 |
08 | while wait() do |
09 | script.Parent.Text = "You have " .. round 1 Place(humanoid.Health) .. " health left" |
10 | end |
11 | --If this helped don't forget to leave a upvote or an accept. |