local down = true
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local we = false
local wee = game:GetService("UserInputService")
wee.InputBegan:Connect(function(input)
if input == Enum.KeyCode.Q then
game.ReplicatedStorage.events.Fire:FireServer()
end
end)
--mouse.KeyUp:Connect(function(key) -- lol i tryed keyheld ;-;
--key = key:lower()
--if key == "q" then
wee.InputEnded:Connect(function(input)
if input == Enum.KeyCode.Q then
print("23")
game.ReplicatedStorage.events.Fire:FireServer()
game.ReplicatedStorage.events.metor:FireServer(game.Players.LocalPlayer:GetMouse())
end
end)
it tryed the user input thing but it dose not do anying thing how do i fix?
2 answers
Hey. Your code is technically right, but it doesn't work for some reason. What you have to do is set a local value with the KeyCode and then check if the KeyCode is Q. It is explained better in this code.
local plr = game.Players.LocalPlayer
local InputService = game:GetService("UserInputService")
InputService.InputBegan:Connect(function(input)
local key = input.KeyCode --Gets the key that the player pressed
if key == Enum.KeyCode.Q then --Checks if the key is Q
--Do whatever here
end
end)
InputService.InputEnded:Connect(function(input)
local key = input.KeyCode
if key == Enum.KeyCode.Q then
--Do whatever here
end
end)
I don't know why this error happens, but this is the way I solved it.
I hope I helped.
-VewixxPlayer
7 comments
Did this work?
Lol. I answered it before you but it is what it is lmao.
yeah
it doesn't matter who replied first
btw VewixxPlayer can u add me?
Never said it mattered its just funny to me.
what do u mean helleric? Roblox friends? If then yes. If there is a friend system on scriptinghelpers also yes xD
On line 8 and 18 you need to change:
if input == Enum.KeyCode.Q then
To the InputObject KeyCode property to compare key codes from the Input
if input.KeyCode == Enum.KeyCode.Q then
2 comments
hmm it worked but it spams
It spams because you arent using debounces or any boolean flags to wait for a x amount of time.
This discussion is preserved as it was. New answers, comments, and votes are closed.

10 comments
can you tell me the errors please? (Check output)
thats the thing there is no error
it is a localscript right?
yeah
Okk I think I solved it
really?
Yes. I also had this problem a few days ago working in my game, so I know how to do it now
ok can u answer it?
I was writing the answer
You are trying to compare a InputObject to a KeyCode. You need to use the dot operator to access the InputObjects properties and scope to the KeyCode property. Hope you learned something.