I have been working on making a health bar compatible with my vehicle. I am using a local script that is parented 5 times under where the value is. The value is working, with the health, but my health bar is not tweening down with health. Please help.
local plr = game.Players.LocalPlayer
local char = plr.Character
repeat wait() until char ~= nil
while wait() do
local life = script.Parent.Parent.Parent.Parent.Parent.Damage.Value
local f = life/500
script.Parent:TweenSize(UDim2.new(f,0,0.654,0),"Out","Linear",0.6)
script.Parent.TextLabel.Text = ""..life.." HP"
end
why are you tweening the entire frame instead of a child of the frame. if you’re tweeing the entire frame then the backgrounds going to also move with that frame and everything inside it.
change script.parent to script.Parent.Healthbar or whatever you are using as the visual color representation on the display to tween. the tween looks ok, if theirs still a problem then start printing your f variable and making a random frame change its size, if that random frame isn’t changing size then you need to change your tween. should work though.
As for not displaying text label, are you sure this is showing already? you should show how it looks when addressing a visual problem cos i have no idea what the problem is with ur txt label (dk the properties)
The problem is that GUI’s clone to LocalPlayer.PlayerGui and the parent will be basically nil. You will need to find the car that the player is using with a way or another and then setting the correct parent.
Name an item in your car head, and make sure it is not transparent. Boom. Ease. I did this with a spaceship by simply adding humanoid and then adding a head, so it would take damage.
As you can see from this link about LocalScripts, LocalScripts only work in the workspace if it is inside the player’s character. Basically, if it is inside the workspace but not inside the character, then it won’t work.
local char = plr.Character
repeat wait() until char ~= nil
the 1st line defines the character and the 2nd line waits until the variable is not nil. But you only defined the variable from the start. Basically, if it is nil, the variable will not update when the character is not nil anymore. So your script will wait forever. So what you would do is
local char = plr.Character
repeat
wait()
char = plr.Character
until char ~= nil
BUT an easier way to wait until character exists is this:
local char = plr.Character or plr.CharacterAdded:Wait()
Also, I recommend putting the ScreenGui inside StarterGui.