Is there a way to equip and unequip items on keypress? It would work with transparency...probably...
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All,false)
And then somehow there is a script when you're holding a tool and when you hit a key (I, Z, E, Q, O, etc.).
I tried this script...made by me...
--- Objects ---- local glass = script.Parent.Parent.Handle --- Scripts ---- function keyDown(key) if key == "I" then glass.Transparency = 0 end end function keyDown(key) if key == "I" then glass.Transparency = 1 end end
It didn't work. Becuase I'm bad a scripting...Don't judge me.
So if you can help me, or show an example? Then I would really appreciate it. Thanks :3
Well you would first off, use UserInputService. When using UIS, here's a few things you should take note of. Connecting a function to UIS's InputBegan
event, there's a parameter that holds the input
. Here's what you would do:
local UIS = game:GetService('UserInputService') local glass = workspace.ExampleGlass -- put glass Reference here local Pressed = false -- a debounce UIS.InputBegan:connect(function(input) if input.KeyCode == Enum.KeyCode.I then if not Pressed then Pressed = true glass.Transparency = 1 else Pressed = false glass.Transparency = 0 end end end)
The input
object is kind of an Instance
since it has properties
One of those properties being KeyCode
, an Enum