How to manage changing the transparency of multiple neon parts? (around 500)

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to change the transparency of multiple neon parts to create different effects such as a strobe effect.

  2. What is the issue? Include screenshots / videos if possible!
    The issue is that I don’t know which is the most efficient way of doing this. I want to avoid causing any lag.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I am currently using tweens to loop the transparency from 0 to 1.

Here are the tweens I have made, one for each speed I want the transparency to change it to.

Module.Tween = {	
	TweenInfo.new(					--[1]SLOW SPEED	
		1.5,						--Number of seconds
		Enum.EasingStyle.Sine,		--How it moves
		Enum.EasingDirection.InOut,	--How it moves
		-1,							--How many times to repeat
		true,						--Go back to start after ending?
		0							--The wait before starting
	), 
	TweenInfo.new(					--[2]REGULAR SPEED	
		1,							--Number of seconds
		Enum.EasingStyle.Sine,		--How it moves
		Enum.EasingDirection.InOut,	--How it moves
		-1,							--How many times to repeat
		true,						--Go back to start after ending?
		0							--The wait before starting
	), 
	TweenInfo.new(					--[3]FAST SPEED	
		.5,							--Number of seconds
		Enum.EasingStyle.Sine,		--How it moves
		Enum.EasingDirection.InOut,	--How it moves
		-1,							--How many times to repeat
		true,						--Go back to start after ending?
		0							--The wait before starting
	), 
	TweenInfo.new(					--[4]RESET LIGHTS
		1,							--Number of seconds
		Enum.EasingStyle.Sine,		--How it moves
		Enum.EasingDirection.InOut,	--How it moves
		0,							--How many times to repeat
		false,						--Go back to start after ending?
		0							--The wait before starting
	)
}

juist loop through all of the neon parts and then find a random tween inside of your module.tweens table and then play the tween, make sure to use ipairs when looping through it

local randomTweenInfo = TweenInfoModule.Tween[math.random(1,#TweenInfoModule.Tween)]

for _, neonPart in ipairs(neonParts:GetChildren()) do
   local tween = TweenService:Create(neonPart, randomTweenInfo, {
      Transparency = math.random(0, 1),
   }) 
end

Yeah that’s what I am currently doing. So I should use tweens then? I’m not too familiar with coroutines but that was somethign I was thinking I could use to.

Well show us the code, all you showed us was a module with the different tween infos you have

this is what I have to make a slow strobe effect.

local StrobeSlow = {}

for _, Lights in pairs(CollectionService:GetTagged(Bulbs[1])) do
	local tween = TweenService:Create(Lights, TweenInfo[1], {Transparency = .8})
	table.insert(StrobeSlow, tween)
	table.insert(mastertweentable, tween)
end

Button[1].MouseButton1Click:Connect(function()
	warn("Strobes Slow Button Pressed")
	warn("Cancelling all tweens")

	for _, tween in ipairs(mastertweentable) do
		tween:Cancel()
	end
	print("All Tweens Cancelled")

	for _, Lights in pairs(CollectionService:GetTagged(Bulbs[1])) do
		Lights.Transparency = 0
	end
	print("All Parts Reset")
	for _, tween in ipairs(StrobeSlow) do
		tween:Play()
		print("Strobe Playing")
	end
end)

Okay I still don’t understand the issue it looks like you’re tweening the transparency here

Like is it working, is it causing lag?

It works fine, I was just wondering if using tweens is the best way of doing it. I’m going to be adding even more neon parts and so I’m worried it could cause lag. Currently there doesn’t seem to be any lag though!

If it aint broke dont fix it, if it’s working fine then don’t worry about it at least for right now anyway

1 Like

Thank you! I’ll leave this unresolved for a bit to wait on any more repsonses. Otherwise I’ll mark your answer as the solution! :sweat_smile: Thanks!

1 Like

Wait I do have one thing though… are you having the clients do the strobe lights or are you having the server do them and then allow replication to do it for all the clients?

Because if you’re doing the ladder… it’s not recommended to have that many tweens playing on the server. It’s too costly and effects like this really should be done on the client, so I suggest you have the server tell the clients to do it locally if you arent already

oof- I am doing it on the server.

Yeah… you’re going to have to have the clients do it on their end which shouldn’t be too hard all you need is to send a remote event using the method FireAllClients, then have the clients do what you’re doing on the server

1 Like

Got it. Would I need to add multiple remote events? Like one for “slow strobe,” “normal strobe,” “fast strobe,” etc? Or can I just use a single one?

Uh, I think you can just have one remote event and then in the argument you can just pass which type of strobe it is and then the client can choose accordingly!

1 Like

Got it! Thank you so much for the help!

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