Wait() statement interrupting the fire rate of my gun

I want to make the PointLight and ImageLabel appear for 0.05 seconds without interrupting my OnServerEvent function.

Currently I have it inside the OnServerEvent function because that is when I want it to appear, but it slows the fire rate of my gun. I have looked on the Dev Forum for a solutions but there weren’t exactly specific keywords I knew to search for.

A piece of my code:

tool.FirePart.RankGui.Enabled = true
tool.FirePart.RankGui.ImageLabel.Rotation = math.random(0,360)
tool.FirePart.PointLight.Enabled = true
wait(0.05)
tool.FirePart.RankGui.Enabled = false
tool.FirePart.PointLight.Enabled = false
wait(tool.Configuration.FireSpeed.Value)
canShoot = true

You will have to spawn it in a new thread. Since its to be ran after a set time, you can use the Delay() function.

Example:

tool.FirePart.PointLight.Enabled = true
task.delay(0.05, function()
     tool.FirePart.PointLight.Enabled = false
end)

However, note that if this entire thing runs again before the delay time is up, it will create oddly timed changes to the light due to it being enabled/disabled at specific intervals. So if you were to run this twice very quickly, it would look like the light only changed once because it sets it to true twice, then false twice. 5 or more times rapidly and it could cause the light to blink very quickly.