Light animation (not lighting) [HELP]

I am making projects that I use for myself and the future, but to also build on top of my current website as a portfolio. If you wish to comment or give a code example, please use pseudo code or use basic references for paths. For example local light = workspace.lamp.light.pointlight.

Goal

I am currently thinking of some kind of sci-fi generator - a part with a slowing neon part and some pointlights - that have a kind of powering up animation accompanied with a sound effect. I was picturing a button on a panel in front of the generator, once pressed, a sound module would play as if it was powering up, then down a bit, then up and repeat.

This might sound stupid and not make much sense for some, but think of the animation as numbers.
1 - 2 - 3 - 2 - 3 - 4 - 3 - 4 - 5

Issue

I do not know how to make them exactly, the animation (the sound I know how to make).

Concern

I was thinking of using Tweens for the light animation by making a table or function that houses every animation or Tween, as some would call it, and then use it as a single variable by calling that function or table when it is to be used. It will look cool, but I am not sure if there are any more efficient ways, or if there are any modules that could help me with this.

•▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬•

Let me know if I have missed something and feel free to link any external links in assistance to solving the issue.

2 Likes

Try using the “bounce”/“elastic” easing style for the lighting Tween. They may give you the “humming” startup effect you desire, but it would be best to experiment with the different types of easing to see if you can get your wanted result.

Hope this helped!

Would the easing style and Tweens in-general work with pointlights too?

Update on the coding process. I have recorded a video to simply showcase my problem.
I’ve tested the back and linear easingstyle, and they both worked the best out of the ones you suggested (and others in Lua’s documentation for EasingStyles) for turning the generator on and off, but for some reason the bounce easingstyle does what I wanted, but then goes backwards after having reached the peak of its power up process.

Here is the code for reference and below it is a video.

-- Variables
local TweenService = game:GetService("TweenService") -- Gets TweenService
local light = workspace["sci-fiGenerator"].Ring.PointLight -- Path to the PointLight
local lightSource = workspace["sci-fiGenerator"].Ring -- Path to the part
local prompt = workspace["sci-fiGenerator"].Button.ProximityPrompt -- Path to the prompt


-- Light Data
local tweenInfo = TweenInfo.new(
	
	10, -- Time the tween takes
	Enum.EasingStyle.Bounce, -- EasingStyle
	Enum.EasingDirection.In, -- EasingDirection
	0, -- Number of times you want it to repeat
	true, -- Do you want it to reverse
	0 -- Delay
	
)


local shutdown = TweenService:Create(lightSource, tweenInfo , {Color = Color3.fromRGB(55, 55, 55)}) -- Creates the tween
local powerUp = TweenService:Create(lightSource, tweenInfo , {Color = Color3.fromRGB(100, 100, 222)}) -- Creates the tween


-- Function to toggle the generator state
local function toggleGenerator()
	if prompt.ActionText == "Turn on" then
		powerUp:Play()
		--light.Enabled = true

		prompt.Enabled = false
		prompt.ActionText = "Turn off"
		wait(10)  -- Wait for the animation to complete
		prompt.Enabled = true
	else
		shutdown:Play()
		--light.Enabled = false

		prompt.Enabled = false
		prompt.ActionText = "Turn on"
		wait(10)  -- Wait for the animation to complete
		prompt.Enabled = true
	end
end

-- Connects the toggle function to the prompt's Triggered event
prompt.Triggered:Connect(toggleGenerator)

If you do not want it to reverse, make sure you set “true” to “false” in the tweenInfo located near “light data” since that controls if it reverses

Aaahhhhhhhhhhhh… I’m so stupid…

I’ve looked at it so many fucking times. I’ve checked it as the first thing. I’ve went into Lua’s documentation for EasingStyles and it said the same thing as you did. I’ve checked it again, I’ve read it by then twice as false. I finally get to you telling me the same thing and feel gaslit by having had to check it again to make sure, and I’ve made sure to read correctly, then realization hits.

Thank you because I would have not checked it a third (3rd) time myself unless I read it somewhere else at some point, which I probably wouldn’t have done.

Although, I do wanna know if there is a way to change its speed (not Tween duration).

1 Like

Speed works relative to the duration, if you want the speed to be faster, then make the duration less, that way it finishes quicker.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.