Connect MouseButton1Click with Specific Keys on Keyboard onto a GUI?
Asked by
7 years ago Edited 7 years ago
This sounds really complicated, but basically, I'm creating a GUI inside a Tool that is basically cloned whenever the Tool is equipped, and inside this GUI I have a button, and what this button does is that whenever it is clicked on, a specific key on the keyboard is pressed. I am a really beginning scripter, and if you guys could fix my script up, it would be awesome!
01 | local Player = script.Parent.Parent.Parent.Parent |
02 | local ScreenGui = script.Parent.Parent |
03 | local Tool = script.Parent.Parent.Parent |
04 | local keys = { false , false } |
05 | local debris = game:service( "Debris" ) |
13 | if Player:IsA( "Player" ) then |
14 | function AroundRight(key) |
15 | if (key = = aroundRight) then |
16 | Tool.rMovement.Disabled = true |
17 | Tool.lMovement.Disabled = true |
18 | Tool.HandValue.Value = 1 |
19 | Tool.GripPos = Vector 3. new( 0.5 , - 0.5 , - 0.3 ) |
21 | Tool.GripPos = Vector 3. new( 0.5 , - 1 , 0 ) |
23 | Tool.GripPos = Vector 3. new( 0.5 , - 1.5 , 0.5 ) |
25 | Tool.GripPos = Vector 3. new( 0.5 , - 1.5 , 1 ) |
27 | Tool.GripPos = Vector 3. new( 0.5 , - 1.5 , 1.5 ) |
29 | Tool.GripPos = Vector 3. new( 0.5 , - 1 , 2 ) |
31 | Tool.GripPos = Vector 3. new( 1 , - 0.5 , 2.5 ) |
33 | Tool.GripPos = Vector 3. new( 1.5 , 0 , 3 ) |
35 | Tool.GripPos = Vector 3. new( 2 , 0.5 , 3 ) |
37 | Tool.GripPos = Vector 3. new( 2.5 , 1 , 3 ) |
39 | Tool.GripPos = Vector 3. new( 3 , 1.5 , 3 ) |
41 | Tool.GripPos = Vector 3. new( 2.5 , 2 , 2.5 ) |
43 | Tool.GripPos = Vector 3. new( 2 , 2.5 , 2 ) |
45 | Tool.GripPos = Vector 3. new( 1.5 , 3 , 1.5 ) |
47 | Tool.GripPos = Vector 3. new( 1 , 3.5 , 1 ) |
49 | Tool.GripPos = Vector 3. new( 0.5 , 3 , 0.5 ) |
51 | Tool.GripPos = Vector 3. new( 0.5 , 2.5 , 0 ) |
53 | Tool.lMovement.Disabled = false |
62 | Tool.Equipped:connect( function () |
63 | script.Parent.MouseButton 1 Click:connect(AroundRight) |
I don't know if I'm suppose to use UserInputService with it or not, or if there's an even simpler method like ContextActionService, but I don't know how to develop the script if I ever tried using those services, lol. (Yet alone even know how to create one.)
All in all, a button that whenever it is clicked on, a key on the keyboard will be equivalent to it, and once the ball is unequipped, the button will disappear. Also, if you could implement a debounce whenever the button is clicked on that would be wonderful! :)
Thanks,
LukeGabriel aka EnergyBrickz