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 8 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:

local replicatedstorage = game:GetService('ReplicatedStorage')
local status = replicatedstorage:WaitForChild('InfoValue')
game.Players.PlayerAdded:connect(function(plr)
    status.Value = plr.Name
end)
  1. (Health) Honestly, I got the script from a model and configured it for a little. So it could represent the player's health:
wait(.1)
local p = script.Parent.Parent.Parent.Parent
local char = p.Character
local h = char.Humanoid
local currentHealth
local f = script.Parent
local text = f.TextLabel
print("yaya")
wait(1)
h.Health = h.Health - 1
while true do
    wait(.1)
    if currentHealth ~= h.Health then
        text.Text = math.floor(h.Health) .. "HP"
    end
end

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