local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
function onkey(key)
if key == "b" -- change to whatever key you want to trigger the function--
then
player.Character.Humanoid.WalkSpeed = 16 * 2.5
endend
mouse.KeyDown:connect(onkey)
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local character = player.Character
local animation = Instance.new("Animation")
animation.AnimationId = "1898738866"
local track = character:FindFirstChild("Humanoid"):LoadAnimation(animation) UIS.InputBegan:connect(function(input, proc)
if not proc then -- So that it wont fire when the player is chatting
if input.KeyCode == Enum.KeyCode.B then --We will see if the key pushed is "B"
track:Play()
character.Humanoid.WalkSpeed = 16 * 2.5
end
end
end) This is what I've tried but it hasn't worked. I put it in workspace. Please tell me what I did wrong!!

3 comments
Put it into a code block next time
And judging by the comments, I'm assuming this isn't your code
Use UserInputService instead.