Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Not showing health for all players?

Asked by 9 years ago

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?

1humanoid = game.Players.LocalPlayer.Character.Humanoid
2function round1Place(x)
3    return (x + 0.05 - (x + 0.05)  % .1)
4end
5 
6while wait() do 
7    script.Parent.Text = "You have " .. round1Place(humanoid.Health) .. " health left"
8end
0
Please write what "working" means. Unclear 1776 — 9y

2 answers

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

Answer this question