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?
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)
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 ~~~~~~~~~~~~~~~~~