Hey Scripters,
I have ran into a problem which I’m not sure of how to figure out when the user pressed the keycode twice. I have tried to figure it but I struggled to do it.
local StarterGui = game:GetService("StarterGui")
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local function Equip(input, gameProcessed)
local num = 1
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.One then
player.Backpack.ClassicSword.Parent = player.Character
script.Parent.Frame.Sword.ImageColor3 = Color3.new(0.0862745, 0.0862745, 0.0862745)
elseif input.KeyCode == Enum.KeyCode.Two then
player.Backpack.RocketLauncher.Parent = player.Character
script.Parent.Frame.RocketLauncher.ImageColor3 = Color3.new(0.0862745, 0.0862745, 0.0862745)
elseif input.KeyCode == Enum.KeyCode.Three then
player.Backpack.ClassicTrowel.Parent = player.Character
script.Parent.Frame.ClassicTrowel.ImageColor3 = Color3.new(0.0862745, 0.0862745, 0.0862745)
elseif input.KeyCode == Enum.KeyCode.Four then
player.Backpack.ClassicTimebomb.Parent = player.Character
script.Parent.Frame.ClassicTimebomb.ImageColor3 = Color3.new(0.0862745, 0.0862745, 0.0862745)
elseif input.KeyCode == Enum.KeyCode.Five then
player.Backpack.ClassicSuperball.Parent = player.Character
script.Parent.Frame.ClassicSuperball.ImageColor3 = Color3.new(0.0862745, 0.0862745, 0.0862745)
elseif input.KeyCode == Enum.KeyCode.Six then
player.Backpack.ClassicSlingshot.Parent = player.Character
script.Parent.Frame.ClassicSlingshot.ImageColor3 = Color3.new(0.0862745, 0.0862745, 0.0862745)
elseif input.KeyCode == Enum.KeyCode.Seven then
player.Backpack.ClassicPaintballGun.Parent = player.Character
script.Parent.Frame.ClassicPaintballGun.ImageColor3 = Color3.new(0.0862745, 0.0862745, 0.0862745)
end
elseif 2 >= num then
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.One then
player.Character.ClassicSword.Parent = player.Backpack
script.Parent.Frame.Sword.ImageColor3 = Color3.new(0.945098, 0.945098, 0.945098)
elseif input.KeyCode == Enum.KeyCode.Two then
player.Character.RocketLauncher.Parent = player.Backpack
script.Parent.Frame.Sword.ImageColor3 = Color3.new(0.945098, 0.945098, 0.945098)
elseif input.KeyCode == Enum.KeyCode.Three then
player.Character.ClassicSuperball.Parent = player.Backpack
script.Parent.Frame.Sword.ImageColor3 = Color3.new(0.945098, 0.945098, 0.945098)
elseif input.KeyCode == Enum.KeyCode.Four then
player.Character.ClassicSlingshot.Parent = player.Backpack
script.Parent.Frame.Sword.ImageColor3 = Color3.new(0.945098, 0.945098, 0.945098)
elseif input.KeyCode == Enum.KeyCode.Five then
player.Character.ClassicTimebomb.Parent = player.Backpack
script.Parent.Frame.Sword.ImageColor3 = Color3.new(0.945098, 0.945098, 0.945098)
elseif input.KeyCode == Enum.KeyCode.Six then
player.Character.ClassicTrowel.Parent = player.Backpack
script.Parent.Frame.Sword.ImageColor3 = Color3.new(0.945098, 0.945098, 0.945098)
end
end
end
end
if UserInputService.KeyboardEnabled then
UserInputService.InputBegan:Connect(Equip)
end
I need a little help, thanks!