I made a gun, and I need to have a flash script whenever it fires. I have a decal on a part that has the flash and it has a point of light. Now, I want to have that flash part show on the gun`s exit hole and dissapear after like 0.1 seconds. This is my script, the basic idea I had:
local flash = game.ReplicatedStorage.Flashes.GunFlash:Clone()
local firesound = game.ReplicatedStorage.Sounds.Fire
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Button1Down:connect(function()
if canShoot == true and sprinting == false then
firesound:Play()
flash.Parent = game.Workspace.Camera:FindFirstChild("Deagle").Deagle.Flame
flash.CFrame = game.Workspace.Camera:FindFirstChild("Deagle").Deagle.Flame.CFrame
wait(0.1)
game.Workspace.Camera:FindFirstChild("Deagle").Deagle.Flame.GunFlash:remove()
end
end)
Explanation: I have a folder that has the flash. I have sounds folder. I also have gun folder but I dont have to use it. I clone the flash to the gun I find inside the Camera (this is a view model), then after 0.1 seconds I remove it. However, this only works once, I see the flash only once but then, no flash.
It says " GunFlash is not a valid member of Part" in the output, and I checked it, it only has the GunFlash part.. no decals or point of light. It Clones the flash once in a correct way, but the second time it wont clone the inside of the GunFlash (decals & light).
Any idea why it works once? Please help me..

3 comments
Try to change the transparency of the GunFlash on fire, and in end fire. on fire put transparency 0 on end fire put transparency 1.
The thing is, it wont work. The GunFlash part is a part that is already transparent. It has 2 decals and a point light. If I would change the transparency of 2 decals and enable and disable the light, it would take too long and be very messy.
And my script is already kind of messy lol