Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can anyone give me some Math help?

Asked by 8 years ago

So I made this hoping that I could effect the new blur effect when someone is dying (losing health) so the blur would get blurrier. but when they heal the number gets higher, it should lower so the blur is not visible, and should get blurrier when they are losing health. But i can't get the math right.

local Player = game.Players.LocalPlayer
repeat wait() until game.Players.LocalPlayer.Character ~= nil
local Char = Player.Character
local Blur = Instance.new("BlurEffect")
Blur.Parent = game.Workspace.CurrentCamera
Blur.Size = 0
local humanoid = game.Players.LocalPlayer.Character.Humanoid
humanoid.HealthChanged:connect(function(health)
    print("")
    print(math.abs(health*health/health/-50))
    --Blur.Size = health*health/health/-99
end)

1 answer

Log in to vote
0
Answered by 8 years ago

For a start, health * health / health is just health. They you are dividing it by -50 and making the blur have a negative size. Thats why you can't see it.

I've made the size go from a maximum of size 2. When the character is at 20 health the blur will no longer be visible. If you want the blur to be visible sooner, increase the number you divide the health by. I used 10 but a value of 20 will cause the blur to be visible at health = 40 (Just do 2*number health is divided by)

local Player = game.Players.LocalPlayer
repeat wait() until game.Players.LocalPlayer.Character ~= nil
local Char = Player.Character
local Blur = Instance.new("BlurEffect")
Blur.Parent = game.Workspace.CurrentCamera
Blur.Size = 0
local humanoid = game.Players.LocalPlayer.Character.Humanoid
humanoid.HealthChanged:connect(function(health)
    Blur.Size = 2-(health/10)
end)

Ad

Answer this question