#InputBegan breaking when given another check

1 messages · Page 1 of 1 (latest)

ivory mortar
#

Associated lines of code (Does not work)

e1 = Uis.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end

    if input.KeyCode == Enum.KeyCode.LeftControl then
        if not ProneAnimationTrack.IsPlaying then
            ProneAnimationTrack:Play()
            if humanoid then
                humanoid.WalkSpeed = 5
            end
        else
            ProneAnimationTrack:Stop()
            if humanoid then
                humanoid.WalkSpeed = 16
            end
        end
    elseif input.KeyCode == Enum.KeyCode.Tab then
        InventoryGui.Enabled = not InventoryGui.Enabled
    end
end)

However if i remove the last keycode check it suddenly starts working

e1 = Uis.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end

    if input.KeyCode == Enum.KeyCode.LeftControl then
        if not ProneAnimationTrack.IsPlaying then
            ProneAnimationTrack:Play()
            if humanoid then
                humanoid.WalkSpeed = 5
            end
        else
            ProneAnimationTrack:Stop()
            if humanoid then
                humanoid.WalkSpeed = 16
            end
        end
    end
end)

I am really confused and i cant understand what can cause this, please help if you can

#

Please ping me if you reply

stuck summit
ivory mortar
ivory mortar
#

this is a really strange issue, its also my first time using the same event for multiple keybinds

#

im kind of confused

#

the issue is from getting playergui

#

the waitforchild never ends

#

nothing to do with input began

ivory mortar
#
local Uis = game:GetService("UserInputService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer

local PlayerGui = player:WaitForChild("PlayerGui")
local InventoryGui = PlayerGui:WaitForChild("InventoryGui")

player.CharacterAdded:Connect(function(character)
    
    local humanoid:Humanoid = character:WaitForChild("Humanoid")

    local animation = Instance.new("Animation")
    animation.AnimationId = "rbxassetid://118410660664793"
    animation.Name = "ProneAnim"
    animation.Parent = humanoid

    local ProneAnimationTrack = humanoid.Animator:LoadAnimation(animation)
    ProneAnimationTrack.Looped = true

    
    local e1
    e1 = Uis.InputBegan:Connect(function(input, gameProcessed)
        if gameProcessed then return end
        print(input.KeyCode)
        if input.KeyCode == Enum.KeyCode.LeftControl then
            if not ProneAnimationTrack.IsPlaying then
                ProneAnimationTrack:Play()
                if humanoid then
                    humanoid.WalkSpeed = 5
                end
            else
                ProneAnimationTrack:Stop()
                if humanoid then
                    humanoid.WalkSpeed = 16
                end
            end
        elseif input.KeyCode == Enum.KeyCode.Tab then

            InventoryGui.Enabled = not InventoryGui.Enabled
        end
    end)

    local e2
    e2 = humanoid.Died:Connect(function()
        e1:Disconnect()
        e2:Disconnect()
    end)
end)

local StarterGui = game:GetService("StarterGui")
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList,false)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
```Here is the entire script if anyone's interested
frail sonnet
ivory mortar
#

I tried putting it inside the tab check and even there it cant get it

frail sonnet
#

btw where is the script

ivory mortar
#

Starterplayerscripts

#

Maybe ill just place it in startergui and get script. Parent

#

It's late so ill update it tomorrow