Is there any way I can make it so only one person can see everyones health?
Each character’s humanoid within the game has a property named “HealthDisplayType” which you can toggle to be “Always Off” like so:
With this you can probably set up some sort of remote to fire the client to toggle that setting on everyone but the player you provide. Pretty sure this should work on the client though I’ve never tested so correct me if I am wrong.
i believe i would put the script in startercharacterscripts right? oh also, how do i detect everyones humanoid?
The client side of your code can be placed within the startercharacterscripts though you still need the server script to fire a remote to your client so it knows when and what players to hide. If you need help ask I can script it and go through the code here.
Could you help me make it so I can detect everyone’s humanoid
Setup
Server
--Define our variables including our services and remote.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HideHealth = ReplicatedStorage:WaitForChild("HideHealth")
--Fire remote to all players to hide certain players health.
wait(5) --Wait for testing purposes.
HideHealth:FireAllClients("50Alpha") --Let's hide my player.
Client
--Define our variables including our services and remote.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HideHealth = ReplicatedStorage:WaitForChild("HideHealth")
--Recive the servers request and hide the players health with a loop
HideHealth.OnClientEvent:Connect(function(Player) --Passed player to hide
for i, v in pairs(game.Players:GetPlayers()) do --Loop through every player do
--v is each player do
local Character = v.Character or v.CharacterAdded:Wait() --Wait for the character.
if v.Name == Player then
--If v's (player) name equals the same to the provided player then contunue
Character.Humanoid.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOn --Toggle health bar off.
else
--If v is not the provided player then toggle it on
Character.Humanoid.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff --Toggle health bar off.
end
end
end)
Where would I put the players username to make it so they can see it
In the server you fire the remote and within that remote I’ve added a parameter where you can input any name you want as long as it is wrapped in “” / string.
i had put my username there and I cant see hp.
Oh sorry, I’ve done it in reverse. Check the code again it should be fixed.
But the code is still the same as before?
No I swapped around Enum.HumanoidHealthDisplayType.AlwaysOff
and Enum.HumanoidHealthDisplayType.AlwaysOn
in the if statements.
My code is functional, I’ve tested it.
Oh, Do the players have to be less than full for me to see it then?
It is set to always on. No matter the health amount it will always be visible.
(Overhead health bars are not visible to yourself. That’s just a Roblox thing.)
Hm. It seems that I can see the other persons health and they can see mine. And if i use a startercharacter with humanoid see health turned off I cant see it with the script working.