Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Not working health gui?

Asked by
Uroxus 350 Moderation Voter
9 years ago

Although this looks long and complicated, its not. It's incredibly repetitive. I'm trying to make a new health Gui for my new game, which doesn't seem to be working. There's no outputs what so ever, the script is a local script, inside StarterGui same as the GUI. All of the health image things that will be shown in the script are image labels. As the script is so repetitive, I'll only post the relevant bits (And don't worry about the spanish numbers, haha)

I think the problem may be not locating the players Humanoid properly. If so, How would I locate it correctly, haha

local gui = game.StarterGui.HealthGui
local health = script.Parent.Parent.Character.Humanoid.Health

----------------------------------------------------
local uno = gui.HealthStorer.First    --1
local dos = gui.HealthStorer.Second   --2
local tres = gui.HealthStorer.Third   --3
local cuatro = gui.HealthStorer.Fourth--4
local cinco = gui.HealthStorer.Fith   --5
local seis = gui.HealthStorer.Sixth   --6
local siete = gui.HealthStorer.Seventh--7
local ocho = gui.HealthStorer.Eight   --8
local nueve = gui.HealthStorer.Nine   --9
local diez = gui.HealthStorer.Last    --10
-----------------------------------------------------
local Red10 = gui.HealthStorer.DeathLast
local Red9 = gui.HealthStorer.DeathNine
local Red8 = gui.HealthStorer.DeathEight
local Red7 = gui.HealthStorer.DeathSeven
local Red6 = gui.HealthStorer.DeathSix


while true do wait()

    if health < 100 and health >= 90 then
        uno.Visible = false and dos,tres,cuatro,cinco,seis,siete,ocho,nueve,diez.Visible == false wait (.25) 
        dos,tres,cuatro,cinco,seis,siete,ocho,nueve,diez.Visible = true


    if health <= 89 and health >= 80 then
        dos.Visible = false and tres,cuatro,cinco,seis,siete,ocho,nueve,diez.Visible == false wait (.25) 
        tres,cuatro,cinco,seis,siete,ocho,nueve,diez.Visible = true


    if health <= 79 and health >= 70 then
        tres.Visible = false and cuatro,cinco,seis,siete,ocho,nueve,diez.Visible == false wait (.25) 
        cuatro,cinco,seis,siete,ocho,nueve,diez.Visible = true


    if health <= 69 and health >= 60 then
        cuatro.Visible = false and cinco,seis,siete,ocho,nueve,diez.Visible == false wait (.25) 
        cinco,seis,siete,ocho,nueve,diez.Visible = true


    if health <= 59 and health >= 50 then
        cinco.Visible = false and seis,siete,ocho,nueve,diez.Visible == false wait (.25)
        seis,siete,ocho,nueve,diez.Visible = true

And so on... Till it gets to

    if health == 1 then _____

The problem is, none of the image labels that are representing the health, are disappearing when health is within the range of the statement. Any help on this would be great. Thanks c:

1
I updated my answer. If it doesn't work, send me another PM. I'll be AFK for an hour. adark 5487 — 9y
1
Oh, nice to see I am not the only one who will name variables or functions in spanish numbers. I have a hard time thinking of good names for some functions and variables xD. M39a9am3R 3210 — 9y
0
Haha, I was going to do them 1,2,3 exc, but figured that may cause some problems and the only other thing I could think of was the Spanish numbers xD Uroxus 350 — 9y

1 answer

Log in to vote
3
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

I'm not actually sure what you want to have happen here, but your problem is that you're trying to write in English what must be written in Lua:

tres.Visible = false and cuatro,cinco,seis,siete,ocho,nueve,diez.Visible == false wait (.25)
cuatro,cinco,seis,siete,ocho,nueve,diez.Visible = true

And the like have to be written like this:

tres.Visible = false
cuatro.Visible = false
cinco.Visible = false
seis.Visible = false
siete.Visible = false
ocho.Visible = false
nueve.Visible = false
diez.Visible = false
wait(.25)
cuatro.Visible = true -- And so on.

EDIT: Additionally, you're setting a variable to a Property, not the Object of that Property (the Humanoid.Health line). This variable doesn't change in accordance with the Humanoid's Health, so you should reference the Humanoid itself instead.

EDIT 2:


local gui = game.Players.LocalPlayer.PlayerGui.HealthGui local health = script.Parent.Parent.Character.Humanoid green = {} ---------------------------------------------------- green[10] = gui.HealthStorer.First --1 green[9] = gui.HealthStorer.Second --2 green[8] = gui.HealthStorer.Third --3 green[7] = gui.HealthStorer.Fourth--4 green[6] = gui.HealthStorer.Fith --5 green[5] = gui.HealthStorer.Sixth --6 green[4] = gui.HealthStorer.Seventh--7 green[3] = gui.HealthStorer.Eight --8 green[2] = gui.HealthStorer.Nine --9 green[1] = gui.HealthStorer.Last --10 red = {} ----------------------------------------------------- red[1] = gui.HealthStorer.DeathLast red[2] = gui.HealthStorer.DeathNine red[3] = gui.HealthStorer.DeathEight red[4] = gui.HealthStorer.DeathSeven red[5] = gui.HealthStorer.DeathSix health.Changed:connect(function() if health.Health > 50 then for _, v in pairs(red) do v.Visible = false end for i = 1, 10 do green[i].Visible = health.Health >= 10*i end else for _, v in pairs(green) do v.Visible = false end for i = 1, 5 do red[i].Visible = health.Health >= 10*i end end end)

EDIT 4: It didn't work because we were changing the StarterGui, not the Player's GUI. I changed Line 1 to reflect this.

0
Thanks for your reply, I've sent you a Pm on roblox which should clear up what should be happening c: Uroxus 350 — 9y
Ad

Answer this question