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

How to show other player's health and name in ScreenGuis?

Asked by 9 years ago

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:

1local replicatedstorage = game:GetService('ReplicatedStorage')
2local status = replicatedstorage:WaitForChild('InfoValue')
3game.Players.PlayerAdded:connect(function(plr)
4    status.Value = plr.Name
5end)
  1. (Health) Honestly, I got the script from a model and configured it for a little. So it could represent the player's health:
01wait(.1)
02local p = script.Parent.Parent.Parent.Parent
03local char = p.Character
04local h = char.Humanoid
05local currentHealth
06local f = script.Parent
07local text = f.TextLabel
08print("yaya")
09wait(1)
10h.Health = h.Health - 1
11while true do
12    wait(.1)
13    if currentHealth ~= h.Health then
14        text.Text = math.floor(h.Health) .. "HP"
15    end
16end

Is there a way I can make similar (or different) scripts so I am able to show other players' Name and Health?

Answer this question