Hello, I am working on a run script for my game.
local UserInputService = game:GetService("UserInputService")
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local animRun = Instance.new("Animation", script.Parent)
animRun.AnimationId = "rbxassetid://14680272756"
local loadRun = char:WaitForChild("Humanoid"):LoadAnimation(animRun)
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
char.Humanoid.WalkSpeed = 35
if loadRun then
loadRun:Play()
end
print("started")
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
loadRun:Stop()
print("stopped")
char.Humanoid.WalkSpeed = 16
end
end)
This script works when the player first spawns, but after dying it breaks. When I press LShift, I can see it still prints “started” however the walk speed stays the same and it doesnt play an animation.
After looking at other post, it may be because of the ragdoll script I’m using, but after analyzing the code I can’t find the cause of the issue.
Ragdoll script: https://create.roblox.com/marketplace/asset/7374049375/Ragdoll-Concept-Open-Source