I solved it myself.

Tried to make a custom GUI for displaying health, but it didn't work. (UDim2.new(0, currentHealth * 2, 0, 15) is used because the frame bar is originally 200 pixels wide)

Please Go to Line 10.

local HealthFrame = script.Parent
local MainFrame = HealthFrame.Parent
local Gui = MainFrame.Parent
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.Character:Wait()
local hum = Char:WaitForChild("Humanoid")
local currentHealth = hum.Health
HealthFrame.Size = UDim2.new(0, currentHealth * 2, 0, 15)
currentHealth.Changed:Connect(function()
	print(currentHealth) -- I changed the CurrentHealth to 1 but it printed out 100... 
	HealthFrame.Size = UDim2.new(0, currentHealth * 2, 0, 15)
end)
while wait() do
	if Char == nil then
		Char = plr.Character or plr:WaitForChild("Character")
	end
end

2 comments

0

Lol i just found what I did wrong........................................ i just did this AGAIN. CurrentHealth doesn't change because its acting as a global variable. Ik its not really one but that's the best way I can explain.

0

And there are other errors in the script that I already catched so yeah no need to answer or comment here. Its working fine now. Only if you have a suggestion then you can comment.