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)
Paste this into a starter charcter script:
local character = game:GetService("Players").LocalPlayer.Character local userInputService = game:GetService("UserInputService") userInputService.InputBegan:connect(function(input) if input.UserInputType == Enum.UserInputType.Keyboard then if input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.RightShift then character.Humanoid.WalkSpeed = 32 end end end) userInputService.InputEnded:connect(function(input) if input.UserInputType == Enum.UserInputType.Keyboard then if input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.RightShift then character.Humanoid.WalkSpeed = 16 end end end)