Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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?

1 comment

0

Script 1, don't wrap in quotations, just leave the variable Key as itself ----> [Key]

2 answers

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

This discussion is preserved as it was. New answers, comments, and votes are closed.