#Need help correctly displaying healthbar value
1 messages · Page 1 of 1 (latest)
Make every healthbar work individually.
elaborate
A script that handles movement should not also handle weapon system.
You can't just make one script that handles everything.
So make each healthbar have It's own script that handles the display on It's own,
ive tried the 2nd part in a different script as well, i just cant get the healthbar do work right
is there something wrong with the script?
let me try makin a script for each healthbar
Where does the health remote event fire from
i have a local script that updates the players own healbar for just their screen gui, when the health is updated for the player it fires the sever
server*
Can you show me how the health GUI is built?
Could you show me the insides of every frame
they all just have 1 image in them
cause its a custom UI
nothing else
any ideas?
yeah
yeah
Put this as server script inside this GUI
local char = script.Parent.Parent
local hum: Humanoid = char:WaitForChild("Humanoid")
local health: Frame = script.Parent.Health
local size
hum.HealthChanged:Connect(function()
size = math.clamp(hum.Health / hum.MaxHealth, 0, 1)
health.Size = UDim2.new(size, 0, 1, 0)
end)
and delete the health remote, its useless now
@analog olive
how so
i swap to the server side view and the healthbar just doesnt change
maybe im missin somethin idk
i change the health value
on the server?
Changing the health value on the client will not change it on the server
what do i gotta do
So you have to pop in server view to actually do changes that replicates to all clients
You have to change it on the server
Otherwise it wont do anything
that?
This has to be saying "Server"
then change the property?
Yh
Yeah and you should be able to test if it actually works
Did you try printing before connecting the event and within the event? Maybe the event doesn't get connected I don't really know where your script is but the WaitForChild could make it wait infinitly
no its in sss
Did you try printing before connecting the event tho?
So just before the HealthChanged event line
I would guess he just put the script within the billboard and didn't check the pathing
** You are now Level 4! **
yh
Having a WaitForChild yield
there is no infinite yield
Or did the gui changing wrong
like try adding this
local char = script.Parent.Parent
local hum: Humanoid = char:WaitForChild("Humanoid")
local health: Frame = script.Parent.Health
local size
hum.HealthChanged:Connect(function()
health:Destroy()
end)
see if it does anything
nothin
does it matter that my GUI is cloned?
from replicated storage
and placed into the head of the player
If it does print, it does run
Did you try literally printing smth at the very first line to see if it even run at all
lmfao
with NOTHING
you did it agian
huh
where the hum.HealthChanged
lower
** You are now Level 10! **
i just didnt show it
replicated
not inside the gui?
the script
the script is in the gUI
But where is the script located within the billboard gui
inthe billboard gui itself
wait i think i have an idea
So like
Overheadhealth
Script
its printing now
ok great, atleast that's progress
its printing ypaypypa everytime?
change the GUI i mean
bro put the size inside healthchanged
You can't know the health ahead of time
the size isnt changing
Just make sure to understand why it wasn't working before
yeah so
why does the variable have to be in the connect function
cause you only defined it once
The function that you define within the HealthChanged connection
gets called each time the health changes
But the variable was define before the health was changed
Staying basically the same
Putting it within the event updates it
thank you guys
Like when its outside the HealthChanged its always the same
when its inside it changes everytime the health value is changed
yeah that makes sense
yh