I’ve been stuck on this for way longer than I should be, Basically I just want a imagelabels transparency to change to 1 once the player has died, and then change back to 0 once the players HP is anything above 1. I dont get why this is wrong, please excuse any mistakes I make, I’m kinda new.
try to make it like this
Gui.Health.Test.Visible = False
im a new scripter but maybe it has to be unvisible
Already tried it, doesn’t work.
The way visibility works, It should be ImageTransparency = 0 to be invisible and 1 to be visible. It is a decimal system.
Im tired, I type that backwards, 1 to be invisible and 0 to be visible
You made a pretty basic mistake aka defining humanoid only once. Every time player respawns, they get a new character with a new humanoid in it. Therefore, you need to get humanoid dynamically, from the current character.
How should I go about doing this??
Yeah, I made a mistake too, still doesnt work though
I wouldn’t use HealthChanged event here. I would use player.CharacterAdded and humanoid.Died events. First of all, connect the character added and then inside the function connect the died event.
You can do, this:
LocalPlayer.CharacterAdded:Connect(function(Character)
Character.Humanoid.HealthChanaged:Connect(function(ActualHealth)
--add if statements
end
end)
More correctly:
player.CharacterAdded:Connect(function(character)
--Hide the image label
character.Humanoid.Died:Connect(function()
--Show the image label
end)
end)
You still haven’t fixed the mistake I told you before.
Don’t define things like humanoid or character at the start of the script.
You can take the humanoid from Character, which you have from the CharacterAdded event.
You can remove that variable and it should work
Not really, I would move the GUI defining of the Gui right before line 5, just create a new line
Alright, I made the change. Though its still not working…
Try putting prints inbettwen the CharacterAdded and the Died events to see if the code is actually being ran.
Another question I have is where is this script located?
I think what you should do is move the localscript from Full to Health and set Full in the explorer to have an ImageTransparency of 0. Then make sure the Health screengui has the property “ResetOnSpawn” Enabled, this will reset the screengui to the default state when the player respawns Then what you could do is
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local healthgui = script.Parent
char.Humanoid.Died:Connect(function()
print("I have died!")
healthgui.Full.ImageTransparency = 1
end
You dont need to do code to reset the transparency to 0 as that is done already when the player respawns