I don't know what's wrong with my script

So I watched this youtube tutorial and I followed everything he did, and when it came time to testing nothing worked. I checked the output, and there wasn’t anything wrong. Anyway this is my script:


local uis = game:GetService("UserInputService")

local re = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")

local db = false

uis.InputBegan:Connect(function(input, GPE)
	if not GPE and not db then
		
		db = true
		
		if input.KeyCode == Enum.KeyCode.M then
			re:FireServer()
			
			wait(5)
			
			db = false
		end
	end
end)

local re = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")

re.OnServerEvent:Connect(function(Player)
	
	local character = workspace:WaitForChild(Player.Name)
	local humanoid = character:WaitForChild("Humanoid")
	
	humanoid.WalkSpeed = 0
	humanoid.JumpPower = 0
	
	local HaoHaki = game:GetService("ReplicatedStorage"):WaitForChild("HaoHaki")
	HaoHaki:Clone()
	HaoHaki.Parent = workspace
	HaoHaki.CFrame = character.HumanoidRootPart.CFrame
	game.Debris:AddItem(HaoHaki, 2)
end)

Put this after the first end there. Otherwise, if you push a different key, the code will never run.

on top of what @JarodOfOrbiter said, you should reverse these arguments.

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

Aren’t they the same arguments or is it different when placed in diff order?

That is incorrect, InputBegan returns the InputObject as the first parameter and a gameProcessEvent boolean as the 2nd parameter, his issue is most definitely that he makes db true regardless if he pressed M or not, it needs to be in the if input.KeyCode == Enum.KeyCode.M if statement

No.
It contains two arguments the first argument is the input of the player and the second argument is the game processed event(to check interaction with UI).
you can name them whatever you want but remember the first argument taken in by the function is the input and the second argument taken in is counted as the GPE which is returned in either false or true.