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

[SOLVED] Why does it take 2 clicks on the same number for my tool to equip?

Asked by 5 years ago
Edited 5 years ago

I need to click a number 2 times for it to work ex. I click 2 1 time and it doesn't do anything. When i click 2 2 times it selects 2.

Warning!(Long piece of code up ahead)

scroll down to see








'
uis = game:GetService("UserInputService")
plr = game.Players.LocalPlayer
ctr = plr.Character or plr.CharacterAdded:Wait()

uis.InputBegan:Connect(function(key, process)
    if process == false then
        if key.KeyCode == Enum.KeyCode.One then
            if plr.Moves.move1.Value ~= "None" then
                if plr.Backpack:FindFirstChild(plr.Moves.move1.Value) == nil then
                    ctr:WaitForChild("Humanoid"):UnequipTools()
                    plr.PlayerGui.Moves.Frame.Move1.Text = plr.Moves.move1.Value
                else
                    ctr:WaitForChild("Humanoid"):EquipTool(plr.Backpack[plr.Moves.move1.Value])
                    lol = plr.Moves.move1.Value
                    plr.PlayerGui.Moves.Frame.Move1.Text = ">"..lol
                    for i = 1, 5 do
                        if i ~= 1 then
                            plr.PlayerGui.Moves.Frame["Move"..i].Text = plr.Moves["move"..i].Value
                        end
                    end
                end
            end
        elseif key.KeyCode == Enum.KeyCode.Two then
            if plr.Moves.move2.Value ~= "None" then
                if plr.Backpack:FindFirstChild(plr.Moves.move2.Value) == nil then
                    ctr:WaitForChild("Humanoid"):UnequipTools()
                    plr.PlayerGui.Moves.Frame.Move2.Text = plr.Backpack[plr.Moves.move2.Value]
                else
                    ctr:WaitForChild("Humanoid"):EquipTool(plr.Backpack[plr.Moves.move2.Value])
                    lol = plr.Moves.move2.Value
                    plr.PlayerGui.Moves.Frame.Move2.Text = ">"..lol
                    for i = 1, 5 do
                        if i ~= 2 then
                            plr.PlayerGui.Moves.Frame["Move"..i].Text = plr.Moves["move"..i].Value
                        end
                    end
                end
            end
        elseif key.KeyCode == Enum.KeyCode.Three then
            if plr.Moves.move3.Value ~= "None" then
                if plr.Backpack:FindFirstChild(plr.Moves.move3.Value) == nil then
                    ctr:WaitForChild("Humanoid"):UnequipTools()
                    plr.PlayerGui.Moves.Frame.Move3.Text = plr.Backpack[plr.Moves.move3.Value]
                else
                    ctr:WaitForChild("Humanoid"):EquipTool(plr.Backpack[plr.Moves.move3.Value])
                    lol = plr.Moves.move3.Value
                    plr.PlayerGui.Moves.Frame.Move3.Text = ">"..lol
                    for i = 1, 5 do
                        if i ~= 3 then
                            plr.PlayerGui.Moves.Frame["Move"..i].Text = plr.Moves["move"..i].Value
                        end
                    end
                end
            end
        elseif key.KeyCode == Enum.KeyCode.Four then
            if plr.Moves.move4.Value ~= "None" then
                if plr.Backpack:FindFirstChild(plr.Moves.move4.Value) == nil then
                    ctr:WaitForChild("Humanoid"):UnequipTools()
                    plr.PlayerGui.Moves.Frame.Move4.Text = plr.Backpack[plr.Moves.move4.Value]
                else
                    ctr:WaitForChild("Humanoid"):EquipTool(plr.Backpack[plr.Moves.move4.Value])
                    lol = plr.Moves.move4.Value
                    plr.PlayerGui.Moves.Frame.Move4.Text = ">"..lol
                    for i = 1, 5 do
                        if i ~= 4 then
                            plr.PlayerGui.Moves.Frame["Move"..i].Text = plr.Moves["move"..i].Value
                        end
                    end
                end
            end
        elseif key.KeyCode == Enum.KeyCode.Five then
            if plr.Moves.move5.Value ~= "None" then
                if plr.Backpack:FindFirstChild(plr.Moves.move5.Value) == nil then
                    ctr:WaitForChild("Humanoid"):UnequipTools()
                    plr.PlayerGui.Moves.Frame.Move5.Text = plr.Backpack[plr.Moves.move5.Value]
                else
                    ctr:WaitForChild("Humanoid"):EquipTool(plr.Backpack[plr.Moves.move5.Value])
                    lol = plr.Moves.move5.Value
                    plr.PlayerGui.Moves.Frame.Move5.Text = ">"..lol
                    for i = 1, 5 do
                        if i ~= 5 then
                            plr.PlayerGui.Moves.Frame["Move"..i].Text = plr.Moves["move"..i].Value
                        end
                    end
                end
            end
        end
    end
end)
0
Be more specific in what the exact issue is. DinozCreates 1070 — 5y
0
:/ HappyTimIsHim 652 — 5y
0
Alright, well my guess is that the value starts out as "none", which makes you unequip tools, then afterwards, you changed the value so that it is not "none" and will then give the player the tool on the second attempt SerpentineKing 3885 — 5y
0
:/ IT STARTS AT NONE not nil! HappyTimIsHim 652 — 5y
View all comments (3 more)
0
So couldn't you make sure that the value is not "none" when you start, then make it "none" when appropriate? SerpentineKing 3885 — 5y
0
why would i make it none? HappyTimIsHim 652 — 5y
0
And there's no error in the output? just to make sure. SerpentineKing 3885 — 5y

Answer this question