Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

it tryed the user input thing but it dose not do anying thing how do i fix?

Asked by 5 years ago
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)
0
can you tell me the errors please? (Check output) VewixxPlayer 67 — 5y
0
thats the thing there is no error helleric -3 — 5y
0
it is a localscript right? VewixxPlayer 67 — 5y
0
yeah helleric -3 — 5y
View all comments (6 more)
0
Okk I think I solved it VewixxPlayer 67 — 5y
0
really? helleric -3 — 5y
0
Yes. I also had this problem a few days ago working in my game, so I know how to do it now VewixxPlayer 67 — 5y
0
ok can u answer it? helleric -3 — 5y
0
I was writing the answer VewixxPlayer 67 — 5y
0
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. Impacthills 223 — 5y

2 answers

Log in to vote
-2
Answered by 5 years ago

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

0
Did this work? VewixxPlayer 67 — 5y
0
Lol. I answered it before you but it is what it is lmao. Impacthills 223 — 5y
0
yeah helleric -3 — 5y
0
it doesn't matter who replied first green271 635 — 5y
View all comments (3 more)
0
btw VewixxPlayer can u add me? helleric -3 — 5y
0
Never said it mattered its just funny to me. Impacthills 223 — 5y
0
what do u mean helleric? Roblox friends? If then yes. If there is a friend system on scriptinghelpers also yes xD VewixxPlayer 67 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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
0
hmm it worked but it spams helleric -3 — 5y
0
It spams because you arent using debounces or any boolean flags to wait for a x amount of time. Impacthills 223 — 5y

Answer this question