Could be issue be happening somewhere else then? Try adding a print after you define your variables
print("WE KNOW THIS WORKS SURELY")
local dummy = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
local hum = dummy:WaitForChild("Humanoid")
local GUI = script.Parent
print("Maybe there isn't a Humanoid in the 7 Parents you referenced?")
local endPos = UDim2.new(hum.Health / hum.MaxHealth, 0, 0, 19)
hum.HealthChanged:Connect(function(dmg)
print("Detected change")
GUI.Size = UDim2.new(hum.Health / hum.MaxHealth, 220, 0, 17)
end)
The issue was most likely caused from the 220 offset in the UDim2, combining with the scale messing the entire thing. Also .HealthChanged returns the current health not damage:
--above code remains the same
local endPos = UDim2.new(hum.Health/hum.MaxHealth, 0, 0, 17)
hum.HealthChanged:Connect(function(health)
GUI.Size = UDim2.new(health/hum.MaxHealth, 0, 0, 17)
end)
--also if 220 was an attempt to scale the bar, just do (health/hum.MaxHealth)*multiplier in scale. With multiplier being the aspect ratio(for example 5)
i found the solution, after looking through everyones comments i realized that the script should be in a local script, and that the offset value has to be 0.