Mobile Reload Button has a delay once clicked

I am making a zombie survival game and am making buttons for mobile compatibility but whenever I test the game and press the button there is a 5 to 7 second delay before the gun reloads but when I press R on my keyboard there is no delay so I’m not sure what the cause of it is.

This is the reload function

userInput.InputBegan:Connect(function(input, gameProcessed)
	
	if not gameProcessed then
		if input.UserInputType == Enum.UserInputType.Keyboard or player.PlayerGui.CameraGui.GameInfo.ReloadButton.MouseButton1Click then
			local keycode = input.KeyCode
			if keycode == Enum.KeyCode.R then
				if gun.Ammo.Value < clipSize and gun.MaxAmmo.Value > 0 then
					shooting = false
					reload:Play()
					reloadAnimation:Play()
					reload.Ended:Wait()
					if gun.MaxAmmo.Value - (clipSize - gun.Ammo.Value) >= 0 then
						gun.MaxAmmo.Value = gun.MaxAmmo.Value - (clipSize - gun.Ammo.Value)
						gun.Ammo.Value = clipSize
					else
						gun.Ammo.Value = gun.Ammo.Value + gun.MaxAmmo.Value
						gun.MaxAmmo.Value = 0
						player.PlayerGui.CameraGui.GameInfo.AmountAmmo.Text = ''.. tostring(ammo.Value)..'/'.. tostring(gun.MaxAmmo.Value)
					end
					
				end	
			end
		end
	end
end)

Is there more code I don’t see the code working in that way

I see this

if keycode == Enum.KeyCode.R then

But no else for if R wasn’t pressed. It just doesnt make sense :thinking: how does it even delay let alone run when Mobile button is pressed.

I don’t really understand. The issue is not with the R keycode, It’s with the mobile reload button

I know but you said that there was a delay looking at the if statement and seeing that there is no else I’m curious on how when you use mobile reload button it actually works.

The button activates around 7 seconds after pressed but not instantly thats why I am calling it a delay

Is the only thing that yields (causes delays) within your script is your sound around 7 seconds long?

That is how long it takes for the reload to complete, not start

And it’s a 1 second long reload sound