Script:
local UIS = game:GetService('UserInputService') local Player = game.Players.LocalPlayer local Character = Player.Character UIS.InputBegan:connect(function(input) if input.KeyCode == Enum.KeyCode.W then local Anim = Instance.new('Animation') Anim.AnimationId = 'rbxassetid://1667958741' PlayAnim = Character.Humanoid:LoadAnimation(Anim) PlayAnim:Play() end end) UIS.InputEnded:connect(function(input) if input.KeyCode == Enum.KeyCode.W then Character.Humanoid.WalkSpeed = 16 PlayAnim:Stop() end end)
It doesn’t work due to deprecated code on lines 5 and 14. Change :connect to :Connect.
To check if two buttons are down (simultaneously) use the UserInputService:IsKeyDown( KeyCode keyCode )
method.
local UIS = game:GetService'UserInputService' local keyCodeQ = Enum.KeyCode.Q local keyCode_E = Enum.KeyCode.E UIS.InputBegan:Connect(function(input, chatting) if chatting then return end if UIS:IsKeyDown(keyCodeQ) and UIS:IsKeyDown(keyCode_E) then -- do code end end)
I used keys E and Q as an example. If both are down at the same time, code will execute.