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

Keybinding not working at all, unable to fix it. What am I doing wrong?

Asked by 5 years ago

Alright so, i'm a relatively new scripter on ROBLOX and i've been trying to figure out what I am missing. Nothing has worked to get this to work and i'm entirely lost on what i'm missing. Basically, i'm trying to get the script to when I hit T it searches to see if the tween is already in position one and if it is, then to move it to position two and vice versa. I was able to get the mouse part to work but I don't know how to do the rest. I want this to be able to be on a loop, meaning it works after one press.

01local frame = script.Parent.Parent.Parent:WaitForChild("Titantrons")
02local frame2 = game.Players.LocalPlayer.PlayerGui.ControlGUI.Frame:WaitForChild("Titantrons")
03local hotkey = Enum.KeyCode.T
04local UIS = game:GetService("UserInputService")
05local toggle = false
06--First Script [For the Keybind]
07UIS.InputBegan:Connect(function(key, gp)
08    if key == hotkey then
09        if UIS:GetFocusedTextBox() == nil then
10        if toggle == false then
11frame2:TweenPosition(UDim2.new(0.003,0,0,0), 'Out', 'Bounce', 1)
12        toggle = true
13    else
14frame2:TweenPosition(UDim2.new(0.003,0,1.3,0), 'Out', 'Bounce', 1)
15        toggle = false
View all 30 lines...

Thanks in advance to anyone who helps.

1
On line 8, to see if key.KeyCode is equal to hotkey, not if key is equal to hotkey. Unhumanly 152 — 5y

1 answer

Log in to vote
1
Answered by
AltNature 169
5 years ago

Add KeyCode at the end of your if key You are confusing the deprecated method Key Down with UIS.

Ad

Answer this question