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

How would I make a space bar thing like mousebutton1down but with space?

Asked by
OFF_S4LE 127
3 years ago

I'm trying to make a frame visible when you press space bar

0
Admin I can't see the note you gave me. OFF_S4LE 127 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

UserInputService may help you with that. UserInputService just allows you to use other keys on the keyboard, and you can use stuff like F4, F5, etc. Put this script in StarterPlayerScripts, and make it a LocalScript. (I'll be using --comments to explain stuff.):

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local plrGui = player.PlayerGui --This gets the Gui, assuming you're using StarterGui.

UIS.InputBegan:Connect(function(input, GPE) --This event will fire, whenever input is pressed. GPE means Game Processed event.
    if GPE then return end --If someone is chatting, then do nothing
    if input.KeyCode = Enum.KeyCode.Space then --If the input is space then
        plrGui.ScreenGui.Frame.Visible = not plrGui.ScreenGui.Frame.Visible --If it's not visible, then it's visible, and vice versa.
    end
end)
0
stonks OFF_S4LE 127 — 3y
Ad

Answer this question