Why is it taking so long for the script to work again

Hello there, there’s a problem that I’m facing right now. This script sometimes stops working after one time or sometimes even takes a while to work again, can someone help me figure out what’s wrong?

-- services
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

-- beam + attachments
local VisionBeam = ReplicatedStorage:FindFirstChild("VisionBeam")
local beam = VisionBeam.Beam:Clone()
local attachment0 = VisionBeam.mindstone.Attachment0:Clone()
local attachment1 = VisionBeam.Part.Attachment1:Clone()

beam.Parent	= workspace.Terrain
attachment0.Parent = workspace.Terrain
attachment1.Parent = workspace.Terrain

beam.Attachment0 = attachment0
beam.Attachment1 = attachment1

-- other variables

local player = game.Players.LocalPlayer
local character = player.Character

-- code

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Q then
		
		local mouse = player:GetMouse()
		RunService.RenderStepped:Connect(function()
			
			beam.Enabled = true
			
			local mindStone = character.MindStone
			
			local origin = mindStone.Position
			local finish = mouse.Hit.p

			attachment0.Position = character.MindStone.Position
			attachment1.Position = finish
			
			character.Humanoid.WalkSpeed = 0
			
			wait(5)
			
			character.Humanoid.WalkSpeed = 16
			
			attachment1:Destroy()
			attachment0:Destroy()
			beam:Destroy()
			
			wait(1)
				
		end)
	end
end)

You have multiple waits() within your script which is not allowing the InputBegan function to start again.
You can avoid this by using coroutines