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

UserInputService does not detect input?

Asked by 3 years ago
Edited 3 years ago

I've made a script that detects when a specific key is pressed. I have tried putting a print function to see if it was detected or not and it did not print the message. Could it be something to do with studio?

Script:

local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local chatting = false
local frame = script.Parent

plr.Chatted:connect(function(msg)
    chatting = false
end)

uis.InputBegan:connect(function(input)
    if input == Enum.KeyCode.Slash and game.StarterGui:GetCoreGuiEnabled("Chat") then
        chatting = true
    elseif input == Enum.KeyCode.Return then
        chatting = false
    end

    if chatting == false then       
        if input == Enum.KeyCode.Equals then 
        frame.Visible = not frame.Visible
        end
    end
end)

I am using a localscript btw

0
are you using a local script or script if its a script it wont work you have to use local script for input techingenius -82 — 3y
0
I am using a LocalScript Defectivethekiller1 72 — 3y
0
you also need gameProcessed as an argument techingenius -82 — 3y

2 answers

Log in to vote
1
Answered by
Fifkee 2017 Community Moderator Moderation Voter
3 years ago

Input.KeyCode, not Input. UserInputService.InputBegan gives you an InputObject as an argument.

0
also please use :Connect for the love of god Fifkee 2017 — 3y
0
Alright lol Defectivethekiller1 72 — 3y
Ad
Log in to vote
1
Answered by
imKirda 4491 Moderation Voter Community Moderator
3 years ago

You have a little mistake out there on line 11:

 if input == Enum.KeyCode.Slash -- no

if input.KeyCode == Enum.KeyCode.Slash -- yes

you forgot to put keycode there, now it should work..

0
oh i was late, damn ok my page did not load imKirda 4491 — 3y
0
Thank you anyways lol Defectivethekiller1 72 — 3y

Answer this question