[Solved Problem] - Help needed with GUI scaling!

Hi guys. Basically, I’m making an Undertale game with the average hp bar. Of course, when you get hit by a sans bone, you can see how much karma is racking up on your health bar. However, I have no idea of how to make that work. I’ve tried dividing, subtracting, and more, but my strength isn’t math, so I’m stumped. If you can help me, I will appreciate you forever!
(For those that have no idea of what I am talking about, here is a link to an Undertale video. It will show you what I mean. Skip to 0:54.)

Script:

local Signal = Humanoid:GetPropertyChangedSignal("Health")
				Signal:Connect(function()
					if Humanoid.Health < HP then -- If the player takes damage.
						HP = Humanoid.Health
						MaxHP = Humanoid.MaxHealth
						local Karma = Humanoid:WaitForChild("Karma", 1)
						if Karma then
							local KR = Karma.KR
							local KarmaChanged = KR:GetPropertyChangedSignal("Value")
							KarmaChanged:Connect(function()
								KRBar.Visible = true
								KRBar.Size = UDim2.new(KR.Value / MaxHP * KR.Value, 0, 0.099, 0)
								KRBar.Position = HPBar.Position
							end)
						else
							print("User is karma free.")
						end
						local Hit = script.Hit:Clone()
						Hit.Parent = Humanoid.Parent
						Hit:Play()
						Hit.Ended:Connect(function()
							Hit:Remove()
						end)
						HPBar.Size = UDim2.new(HP / MaxHP * 0.267, 0, 0.099, 0)
						HPText.Text = tostring(math.round(HP).."/"..math.round(MaxHP))
			--			KRBar.Position = HPBar.Size+UDim2.new(0.234, 0, 0.001, 0)
						print("Got hit. HP: "..HP)
					elseif Humanoid.Health > HP then -- If the player heals
						HP = Humanoid.Health
						MaxHP = Humanoid.MaxHealth
					end
					local Heal = script.Heal:Clone()
					Heal.Parent = Humanoid.Parent
					Heal:Play()
					Heal.Ended:Connect(function()
						Heal:Remove()
					end)
					HPBar.Size = UDim2.new(HP / MaxHP * 0.267, 0, 0.099, 0)
					HPText.Text = tostring(math.round(HP).."/"..math.round(MaxHP))
				--	KRBar.Position = HPBar.Position+UDim2.new(0.234, 0, 0, 0)
					print("Got hit. HP: "..HP)
				end)

I apologize if the code is messy. The only part that I think you need to worry about is the KRBar sizing crap. But I gave more than that bit just in case.

1 Like

How did you solve that? Make a post and make it solved so we know it is solved