Creating Scalers! Help!

Hey everybody! I have to learn how to do this, so can one of you big brains teach me how to create a scaler? I’m trying to make it so when your character takes damage, it increases a BlurEffect’s size, and when you heal, it reverses it little by little. I need to learn the math behind it and I want the Blur Size to be 15 by the time the player’s health is 0. How do I do this?

you could interpolate it, knowing theres 100 hp just set the parametric term to current health / 100 and then have that be the blur size. taking damage is pretty straight forward just do some debounce stuff and touched events

2 Likes

No disrespect, but did you even read what I asked for?

blur.Size = (1 - hp / maxHp) * 15
1 Like

yes i did, is there something you dont understand with my response

To bank off what @heII_ish said

--Script inside of StarterCharacterScripts
local humanoid = script.Parent:FindFirstChild("Humanoid")

humanoid.HealthChanged:Connect(function(newHealth)
  --newHealth / humanoid.MaxHealth: Get the percentage of the health
  --1 - (newHealth / humanoid.MaxHealth): Subtract the percentage from 1 to get how far under 100 we are
  --Finally, multiply by 15 to set the size of the blur accordingly.
  game.Lighting.Blur.Size = (1 - (newHealth / humanoid.MaxHealth)) * 15
end)

I asked for help learning the math behind the operation. Hellish went the extra mile and gave me the equation, but I want to learn the logic behind the math.

all they are doing is getting the ratio of the current hp and the max hp, then they invert it cause you wanted it to be when it at 0 it is 15, anything times 1 is itself cause 1 is the multiplicative identity