Effect only plays when I spam click

I have a gun with an effect that plays when you click, for some reason, it only plays once when you click multiple times.

This is my code:

Local script in tool

uis.InputBegan:Connect(function(input, processed)

	if processed then return end
	if focused == false then return end

	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		script.Fire:FireServer()
	end

end)```

ServerScript inside of local script

local sounds = script.Parent.Parent.Handle.Grip
local effects = sounds.Muzzle
local debounce = false

script.Parent.Fire.OnServerEvent:Connect(function(player)
if debounce == false then
debounce = true
for _, effect in pairs(effects:GetChildren()) do

		effect.Enabled = true
		wait(0.1)
		effect.Enabled = false

	end
	sounds.Fire:Play()
	task.wait()
	sounds.Echo:Play()
	
	task.wait()
	debounce = false
end

end)

1 Like

It could be since you are using a wait everytime to make an effect appear, Instead, Use the :Emit(number) Function, (number being the amount of particles you want to emit) Also, You should probably insert a number into those task.waits,

And another thing, Use ``` at the start and end of your script when posting, like this

code 
stuff
1 Like

Thanks! That seemed to fix it.

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