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

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!

01local Player = script.Parent.Parent.Parent.Parent
02local ScreenGui = script.Parent.Parent
03local Tool=script.Parent.Parent.Parent
04local keys={false,false}
05local debris = game:service("Debris")
06 
07------------------------------------------------
08local aroundRight="g" -- the key pressed
09-------------------------------------------------
10 
11while true do
12    wait()
13    if Player:IsA("Player") then
14        function AroundRight(key) --this is what happens to the tool (basically a basketball)
15        if (key==aroundRight) then
View all 64 lines...

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

1 answer

Log in to vote
1
Answered by 7 years ago

I think i got it. The problem that i see was in the while loop. The code below while will be executed when its condiction is false. As your loop's condiction is directally set to true, the code will not be executed anyhow...

0
so what do i do gg LukeGabrieI 73 — 7y
0
omg 2 months later lul. So... you should put the loop in the end of the code arthurgps2 67 — 7y
Ad

Answer this question