How to show other player's health and name in ScreenGuis?
I was making a fighting game and I wanted to show different players' Name and Health. However, I could only make the Gui for my playing player. Here are my codes:
1. (Name) I used StringValue, a LocalScript in TextLabel it could connect to the StringValue from ReplicatedStorage:
1 | local replicatedstorage = game:GetService( 'ReplicatedStorage' ) |
2 | local status = replicatedstorage:WaitForChild( 'InfoValue' ) |
3 | game.Players.PlayerAdded:connect( function (plr) |
4 | status.Value = plr.Name |
- (Health) Honestly, I got the script from a model and configured it for a little. So it could represent the player's health:
02 | local p = script.Parent.Parent.Parent.Parent |
03 | local char = p.Character |
04 | local h = char.Humanoid |
06 | local f = script.Parent |
07 | local text = f.TextLabel |
10 | h.Health = h.Health - 1 |
13 | if currentHealth ~ = h.Health then |
14 | text.Text = math.floor(h.Health) .. "HP" |
Is there a way I can make similar (or different) scripts so I am able to show other players' Name and Health?