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

No error but it don t work (keybind test for magic) can you help me?

Asked by 4 years ago

script 1

local magic = game.Players.LocalPlayer.Backpack:WaitForChild("Magic")
local key = script:WaitForChild("Key")

game:GetService("UserInputService").InputBegan:connect(function(KeyInput)
        if KeyInput.KeyCode == Enum.KeyCode["Key"] then
            print("OMG")
        end
    end)

script 2

local magic = game.Players.LocalPlayer.Backpack:WaitForChild("Magic")
local text = script.Parent.Input
local key = magic:WaitForChild("Key")

script.Parent.Input:GetPropertyChangedSignal("Text"):Connect(function()
    if magic.MagicLOL.Value == true then
        key.Value = text.Text
        wait (1)
        print(key)
    end
end)

can anyone help me?

0
Script 1, don't wrap in quotations, just leave the variable Key as itself ----> [Key] Ziffixture 6913 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
local magic = game.Players.LocalPlayer.Backpack:WaitForChild("Magic")

game:GetService("UserInputService").InputBegan:connect(function(KeyInput)
    if KeyInput.KeyCode == Enum.KeyCode.T -- Change T  to whatever key you want to fire the function.
        print("OMG")
    end
end)
Ad
Log in to vote
0
Answered by
Arj783 72
4 years ago
Edited 4 years ago

Script 1 has to be a localscript in starterpack/startergui.

Also, in script 1, you wrote:

if KeyInput.KeyCode == Enum.KeyCode["Key"] then

Don't put it in speech marks (Quotations)

~~~~~~~~~~~~~~~~~ if KeyInput.KeyCode == Enum.KeyCode[Key] then ~~~~~~~~~~~~~~~~~

Answer this question