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

GUI Toggle script doesnt scan for RightShift Input?

Asked by 2 years ago

btw there is a value inside of the GUI so that i know if its Visible so i can spend less time lol

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(key)
    if key == Enum.KeyCode.RightShift then
        if script.Parent.Visible.Value == true then
            script.Parent.BottomFrame.Visible = false
            script.Parent.Frame.Visible = false

        else
            script.Parent.BottomFrame.Visible = true
            script.Parent.Frame.Visible = true

        end

    else
        return
    end
end)
0
and yes the Value is a Bool Black_Magic2533 104 — 2y
0
boolValues can be changed locally and globally that why its not working because for the server the value still appears as false. Replace that boolValue with a simple local Value = false and tell me if it works VAnkata20 135 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

InputBegan gives “input”, not “key”, also, it’s not the KeyCode itself. You need to do Input.KeyCode to compare the keys. So something like

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.RightShift then
        --yes shift
    else
        --no shift
    end
end)
0
it doesn't matter what you name the argument, it works either way with "input" or "key" boredlake 256 — 2y
0
That is in fact true, I should have worded my sentence more appropriately. However “key” does not really represent what the argument is, so it is still generally advised to name it “input”. SuperLittleAdmin 257 — 2y
Ad

Answer this question