local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local function onInputStarted(inputObject, processedEvent)
if processedEvent then return end
if inputObject.KeyCode == Enum.KeyCode.LeftShift then
local character = Players.LocalPlayer.Character
if not character then return end
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid then return end
humanoid.WalkSpeed = 20
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local runAnimation = Instance.new("Animation")
runAnimation.AnimationId = "rbxassetid://119708205580016"
local runAnimationTrack = animator:LoadAnimation(runAnimation)
runAnimationTrack:Play()
end
end
local function onInputEnded(inputObject, processedEvent)
if processedEvent then return end
if inputObject.KeyCode == Enum.KeyCode.LeftShift then
local character = Players.LocalPlayer.Character
if not character then return end
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid then return end
humanoid.WalkSpeed = 12
local runAnimation = Instance.new("Animation")
runAnimation.AnimationId = "rbxassetid://119708205580016"
local runAnimationTrack = animator:LoadAnimation(runAnimation)
runAnimationTrack:Stop()
end
end
UserInputService.InputBegan:Connect(onInputStarted)
UserInputService.InputEnded:Connect(onInputEnded)```
#???
1 messages · Page 1 of 1 (latest)
What's wrong with your script
Give me an output error
I think when you're release a shift button, the humanoid walkspeed should be set by 16 instead of 12
You forgot to get the animator in the inputEnded function