Why doesnt this reload script work?

local function onKeyPress(input)
if input.KeyCode == Enum.KeyCode.R then
print(‘reloaded’)
wait(1)
ammo = maxAmmo
end
end

uis.InputBegan:Connect(onKeyPress())
Why doesnt this code work? It is in a script in a tool.

you are firing the function instead of setting it as an argument.
remove the parenthesis within onKeyPress() in :Connect()

It pronts reloaded, however doesnt actually reload. I tgink that is more a of a module script rpoblem, so thanks for this advice.