Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can you help me with my Neon effects?

I have this Neon effect where your characters body glows for a few seconds before quickly dissapearing, I'm half-way there but I've come to a halt.

This is what it looks like so far: Glow

I want all the blocks to do this at the same time, this is the code I'm using:

	for _, child in next, Player.Character:GetChildren() do
 
		if child:IsA("Part") then
	
			local effect = child:Clone()
		
			for transparency = 0, 1, 0.2 do
	
				effect.BrickColor = BrickColor.new("Black")
							
				effect.Transparency = 0.5
						
				effect.Anchored = true
						
				effect.CanCollide = false	
							
				effect.Material = 288
							
				effect.Parent = workspace
							
				effect.Transparency = transparency
										
				effect.Size = effect.Size + Vector3.new(0.1, 0.1, 0.1)
												
				wait()
end	           
	
	end	
			
		end

Thank you in advance.

1 answer

✓ Accepted answer

##Problem

The problem you're having is the script is going through a loop with a wait. With that wait the loop will hold up other aspects of the script and provide the result you see. Loops are difficult as it is hard to make it run simultaneously only using them.


##Solution

The solution to your problem would be to thread the loop. By this I mean the code will run simultaneously in its own thread. Almost as if the function is running within another script. YonaJune and BlueTaslem can probably get in depth with threading and so forth. How you can accomplish this is either by using Spawn() or coroutine.wrap()(). All you would have to do is wrap the for loop for transparencies into its own thread. For my edit of the script, I used Coroutine.wrap since I believe I've had problems before with the spawn function.


##Final Script

for _, child in next, Player.Character:GetChildren() do
    if child:IsA("Part") then
        local effect = child:Clone()
        coroutine.wrap(function()
        	for transparency = 0, 1, 0.2 do
                effect.BrickColor = BrickColor.new("Black")
                effect.Transparency = 0.5
                effect.Anchored = true
                effect.CanCollide = false   
                effect.Material = 288
                effect.Parent = workspace
                effect.Transparency = transparency
                effect.Size = effect.Size + Vector3.new(0.1, 0.1, 0.1)
                wait()
            end
        end)()            
    end 
end

######Hopefully this answered your question, if so hit the accept answer button. If you have any questions feel free to comment below.

1 comment

0

Thanks man, you helped a lot.

This discussion is preserved as it was. New answers, comments, and votes are closed.