I am currently facing challenges with a script implementation in my game, and I would sincerely appreciate your expertise and assistance.
The script in question manages a health UI, positioned within the StarterPlayerScripts folder, designed to function as a standard overhead health bar. My objective is to configure it in a way that the local player is unable to view their personal health bar while ensuring that other players can observe their respective health bars. Your support in resolving this matter would be invaluable to me, and I am genuinely grateful for any insights or guidance you may provide.
I am currently experiencing an issue where the health bar is not visible to the local player, which aligns with my intended configuration. However, it appears that other players are unable to see the health bars.
paste your code instead of screenshotting so people can properly help you
your script should be a LocalScript and if it already is
then you have no reason to be checking if you are the LocalPlayer
just do
local TS = game:GetService("TweenService") -- Use TweenService instead
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
Ah, thanks for the feedback there. Here is the script in text form: local char = script.Parent
local healthGui = script.HealthGui
local humanoid = char:WaitForChild(“Humanoid”)
healthGui.Parent = char.Head
local player = game.Players:GetPlayerFromCharacter(char)
local isLocalPlayer = player and player == game.Players.LocalPlayer
if isLocalPlayer then
healthGui.Enabled = false – Hide the health bar for the local player
end
local function updateHealth()
local healthChange = humanoid.Health / humanoid.MaxHealth
local healthColor = Color3.fromRGB(255, 0, 0):Lerp(Color3.fromRGB(60, 255, 0), healthChange)
healthGui.Health.Meter:TweenSize(UDim2.new(healthChange, 0, 1, 0), "In", "Linear", 0.5)
healthGui.Health.Meter.BackgroundColor3 = healthColor
end
humanoid:GetPropertyChangedSignal(“Health”):Connect(updateHealth)
– Call updateHealth once to initialize the health bar
updateHealth()