I got this from a tutorial, since I'm a beginner scripter, but I tried to script it so when you hold it, you'll run, and an animation plays, and when you stop, it goes back to the default animation and walk speed, but I can't seem to script it that way, can someone help me? That would be nice. If you think this question is not constructive, I'll take it down, here is the script.
local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local character = player.character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local uis = game:GetService("UserInputService")
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://5044642525"
function onKeyPressed(inputObject, gameProcessEvent)
if inputObject.KeyCode == Enum.KeyCode then
humanoid:LoadAnimation(anim):Play()
humanoid.WalkSpeed = 16*2
end
end
uis.InputBegan:Connect(onKeyPressed)

9 comments
I get these three errors: 19:47:49.343 - Walkspeed is not a valid member of Humanoid, 19:47:50.894 - Keycode is not a valid member of InputObject and 19:48:43.826 - Touched is not a valid member of Script
Actually just ignore the "Touched" error, that's from another script.
First you have to check if you have a local script inside of the startercharacterscripts folder
also you can add a wait(10) on the top of the script
That's not what I meant, I need to remove these errors, and if i add wait(10), nothing different happens.
Oh, and I forgot to tell you, you need to run an animation. Sorry!
i told you to use wait becauuse you said that you got an error called Walkspeed is not a valid member of humanoid
Also have you even tried how it look when you just change the walkspeed
oh my gosh, i am so dumb, i must have made an error in my code, sorry!