#Health GUI Script

225 messages · Page 1 of 1 (latest)

shut summit
#

just set the text to
local hp = 100
gui.Text = hp .. "/100"

#

And decrease hp then update the text

wispy fulcrum
#

?

#

i don't really understand im not a good scripter

#

could u explain

shut summit
#

like

local hp = 100
local gui = script.Parent
function update()
      gui.Text = hp.."/100"
end
update()
hp -= 1 
update()

etc

wispy fulcrum
#

this is what the free model gave me (it had alot more stuff i deleted them)

shut summit
#

In a localscript

wispy fulcrum
shut summit
#

In amountlabel

wispy fulcrum
#

alright wait

shut summit
uneven comet
#

Good

wispy fulcrum
#

like this?

shut summit
#

yes

wispy fulcrum
#

now?

shut summit
#

Test it

wispy fulcrum
#

alright wait

#

nope

#

i made it full green slider and renamed "n/a" to 100

#

as u told me

shut summit
#

is background the green bar ?

wispy fulcrum
#

wdym?

shut summit
wispy fulcrum
#

nope

#

slider is green bar

shut summit
#

K

wispy fulcrum
#

background is like moving the whole thing

#

slider

shut summit
#
local hp = 100
local gui = script.Parent
local bar = script.Parent.Parent.Background.Slider  
function update()
      gui.Text = hp.."/100"
      bar.Size = UDium.fromScale(1,hp/100)
end
update()
hp -= 1 
update()
wispy fulcrum
#

wait let me try

potent burrowBOT
#

studio** You are now Level 3! **studio

wispy fulcrum
#

still doesnt work

shut summit
#

mb not slider.Size but bar.Size

wispy fulcrum
#

oh

#

still not

#

working

#

is it the right place for the localscript?

shut summit
#

Yes it should be the right place

#

Any error?

#

O yes

#

UDim2 not Udim

wispy fulcrum
#

still not

shut summit
#

Change the size manually in the explorer

wispy fulcrum
#

size of?

shut summit
#

The green bar

wispy fulcrum
#

to what

#

?

shut summit
#

or try

local hp = 100
local gui = script.Parent
local bar = script.Parent.Parent.Background.Slider  
function update()
      gui.Text = hp.."/100"
      bar.Size = UDium2.fromScale(hp/100,1)
end
update()
hp -= 1 
update()
uneven comet
#

Anything, just make sure it’s only the green bar, then look what it’s called

wispy fulcrum
#

nope

#

still doesnt work

#

i did what u guys told me

shut summit
#

So the green bar is probably not slider

wispy fulcrum
#

it is

#

can u dm and ill screenshare?

shut summit
#

Nah I can't

wispy fulcrum
#

uhh

#

ill record then

#

1 sec

shut summit
#

If you want the size of the bar does it work ?

wispy fulcrum
#

there

bronze palm
#

those errors are killing me

wispy fulcrum
#

i just want this specific gui i wouldn't bother u if i wished to use another one

wispy fulcrum
bronze palm
wispy fulcrum
bronze palm
wispy fulcrum
#

OH

#

wait

#

@shut summit

#

there

#

this is an error for the gui

shut summit
#

o

#

UDim2

wispy fulcrum
#

can yall tell me what this is its like 5k times per start

shut summit
#

not UDium2

bronze palm
#

was about to say

wispy fulcrum
bronze palm
#
local hp = 100
local gui = script.Parent
local bar = script.Parent.Parent.Background.Slider  
function update()
      gui.Text = hp.."/100"
      bar.Size = UDim2.fromScale(hp/100,1)
end
update()
hp -= 1 
update()```


here's the fixed version
shut summit
#

Yes it works

bronze palm
#

works like a charm

potent burrowBOT
#

studio** You are now Level 4! **studio

wispy fulcrum
#

doesnt work

#

neither of them

#

do yall have time to join co op to fix?

shut summit
#

Change hp to 40

#

(the variable)

wispy fulcrum
#

variable like in..?

#

properties or?

#

script

shut summit
#

local hp = 40

wispy fulcrum
#

the bar works but when i get damaged

#

it doesnt do anything

#

also why does it say 39 when its put on 40

#

i get -1 hp on the bar

bronze palm
#
game.Players.LocalPlayer.CharacterAdded:Connect(function(char)
    local gui = script.Parent
    local bar = script.Parent.Parent.Background.Slider  
    local function update()
        local hp = char.Humanoid.Health
        gui.Text = hp.."/100"
        bar.Size = UDim2.fromScale(hp/100,1)
    end
    char.Humanoid.GetPropertyChangedSignal("Health"):Connect(update)
end)
shut summit
#

^

bronze palm
#

quite basic but should work

bronze palm
#

too lazy to rewrite the old code, just wrapped it inside a function so it updates on health change

#

forgot something vital

#

char.Humanoid

#

should be working now

wispy fulcrum
#

still no

bronze palm
#

could've also used HealthChanged but forgot about that function

#

oh wait I'm dumb

wispy fulcrum
#

?

bronze palm
#

hp needed to go inside the function

#

not outside of it

wispy fulcrum
#

what do i do

shut summit
#

local char = nil
local event = nil
local gui = script.Parent
local bar = script.Parent.Parent.Background.Slider  

local function update()
    gui.Text = char.Humanoid.Health.."/100"
    bar.Size = UDim2.fromScale(char.Humanoid.Health/100,1)
end
game.Players.LocalPlayer.CharacterAdded:Connect(function(c)
   char = c
   if event then event:Disconnect() end  
event =   char.GetPropertyChangedSignal("Health"):Connect(update)
end)
bronze palm
#

does the client know that the health is lost?

shut summit
#

Any error ?

wispy fulcrum
#

cuz there is nothing inside replicatedstorage

#

so

shut summit
#

This problem is from another script

wispy fulcrum
#

i guess

#

there is nothing about gui i think let me check

#

nope

#

no errors for gui

shut summit
#

For character / humanoid?

wispy fulcrum
#

nope

shut summit
#

Print something after char = c and in the function update

wispy fulcrum
#

this...?

#

wait i forgot ""

#

there

shut summit
#

yes

wispy fulcrum
#

alright wait

#

now?

shut summit
#

does it print?

wispy fulcrum
#

i think this is it

#

wait

shut summit
#

o

#

event = char.Humanoid.GetPropertyChangedSignal("Health"):Connect(update)

wispy fulcrum
#

maybe its cuz i have all these frames, what if i delete them and make a new frame with the same ui

wispy fulcrum
shut summit
#

Nah don't delete them

#

event = char.Humanoid:GetPropertyChangedSignal("Health"):Connect(update)

wispy fulcrum
#

doesn't work

#

did i put anything wrong inside

shut summit
#

Is it the entire script ?

wispy fulcrum
#

yes

shut summit
#

(with "end)" at the end )

wispy fulcrum
wispy fulcrum
shut summit
#

add end) at the end

wispy fulcrum
#

oh

#

this?

shut summit
#

Yes

wispy fulcrum
#

humanoid error

#

also

#

it doesnt work

#

the health bar didnt go down

shut summit
#

Go in the explorer -> workspace -> your character then send a screenshot

wispy fulcrum
shut summit
#

replace l 13 by
char:WaitForChild("Humanoid"):GetPropertyChangedSignal("Health"):Connect(update)

wispy fulcrum
#

wtfff mann why wont it work

#

i did everything

#

it doesnt wanna work

#

im telling u its probably because of all these frames this model had alot of stuff inside i removed most of them

#

ill try to make the gui in 1 frame only wait

#

if it doesnt work ill undo

#

nvm

#

it doesnt work

#

can anyone come in co op and fix or something

#

@shut summit any other solutions?

#

ill just find another ui and it will probably be easier

potent burrowBOT
#

studio** You are now Level 5! **studio

wispy fulcrum
#

this one is messed up so many frames and stuff

gloomy mirage
#

u still

#

have that bug?

wispy fulcrum
#

well i gave up on health bar since that was best gui i could find other ones are basic and yea i cant make good ui's

gloomy mirage
#

I here

#

When me here

#

Everything solved

wispy fulcrum
#

cuz its probably impossible

gloomy mirage
#

Nothing impossible

#

Except me delete my lazyness

wispy fulcrum
#

bro can u tell me one thing

#

i cant find my terrain

#

help

#

like

#

im lost in sky

gloomy mirage
#

Wjwuwhuwuwvwuwvs

#

Create new one

#

How tf u lose ur baseplate

wispy fulcrum
#

i imported something and dissapeared

#

magik

#

@gloomy mirage im trying to use this model for animation with katana if it works then u can help me with health bar

#

or if ur good at gui maybe u can help me make one that i want

#

if not thats alright

gloomy mirage
#

I can help healthbar but not katana animation i hate animations

wispy fulcrum
#

yea im gonna do animation by myself

#

im doing it rn

gloomy mirage
#

So what healthbar

#

Issue

#

U have

wispy fulcrum
#

are u good at making gui's

#

?

gloomy mirage
#

Put ur script here with ur issue, I will check later when I wake up

#

And no i just

#

Scripter

wispy fulcrum
#

im gonna be a grandpa by then