Damage lightning effect

Hello everyone,
I’ve been working on a lightning damage effect, so when the player damages, the lightning enables.
I tried a lot of different ways to tween it and nothing seems to work, any help?

script:

local tweenService  = game:GetService("TweenService")

while true do
	if script.Parent.Humanoid.Health <= 50 then
		game.Lighting.ColorCorrection.Enabled = true
		TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
	else
		game.Lighting.ColorCorrection.Enabled = false
		TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
	end
	wait()
end

I never experienced tweening with lightning before, I’m sorry if the script does not make any sense.
Thanks in advanced.

Have you worked with TweenService at all?

Yeah, not a lot tho. I never experienced lightning tween which is confusing me a lot

Okay, well part of the problem is that you didn’t properly create tweens.

What exactly are you trying to tween? From what I can see, you’re only providing tweeninfo for a tween that you haven’t created.

Here’s an example of a tween:

local ts = game:GetService("TweenService")
local ti = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local part = --define part or object here

local tweenProperties = {
    --Write your changed properties here
}

------------------
--CREATE A TWEEN--
------------------
local tween = ts:Create(part, ti, tweenProperties)

wait()

tween:Play()

Try this:


while true do
	if script.Parent.Humanoid.Health <= 50 then
		game.Lighting.ColorCorrection.Enabled = true
		local Information = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
        TweenService:Create(-- your object here, -- Information, Properties-- What you want to tween)
	else
		game.Lighting.ColorCorrection.Enabled = false
				local Information = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
                TweenService:Create(-- your object here, -- Information, Properties-- What you want to tween)
	end
	wait()
end

Although @anon36900032’s example provides a bit more information on how to tween it.

1 Like

My bad, I forgot to add tweenService:Create I didnt even notice lol

My problem is, How would I define the lightning object?
would I define it as game.Lighting:WaitForChild(“ColorCorrection”)?

Well, what exactly is the lightning object? The colorCorrection effect?

Also, what are you tweening?

The lightning object is color correction.
I’m tweening the lightning effect, so when the color correction is enabled, it tweens in smoothly

If it’s enabled, then it won’t appear smoothly. It will just become enabled. You cannot tween a boolvalue, which in this case, would be Enabled.

Yeah thats what I thought, Would a saturation setting work with a tween?

Yes, but I recommend tweening the color of the ColorCorrectionEffect, then tweening it back to the default Color3.

Thank u tho, helped a lot. I think I will make the screen shake so it will work better and wont look choppy.

No problem, good luck. :grinning_face_with_smiling_eyes:

1 Like

As others have been mentioning you with the Tween I would suggest you,use the HealthChanged Event on the Humanoid as it will be way more effective
Humanoid.HealthChanged:Connect(function(health)
if health <= 50 then
–do what you want
end
end)

1 Like