local CAS = game:GetService("ContextActionService")
local UIS = game:GetService("UserInputService")
local jumpDisabled = false
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local hum = char:WaitForChild("Humanoid")
local run_Anim = hum:LoadAnimation(script:WaitForChild("ExportAnim"))
function onJump()
if jumpDisabled then
hum.Jump = false
end
end
function toggleSprint(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
hum:LoadAnimation(script:WaitForChild("ExportAnim")):Play()
hum.WalkSpeed = 35
jumpDisabled = true
elseif inputState == Enum.UserInputState.End then
hum:LoadAnimation(script:WaitForChild("ExportAnim")):Stop()
hum.WalkSpeed = 16
jumpDisabled = false
hum:LoadAnimation(script:WaitForChild("WalkAnim")):Play()
end
end
function windowFocused()
hum:LoadAnimation(script:WaitForChild("ExportAnim")):Stop()
hum.WalkSpeed = 16
jumpDisabled = false
end
CAS:BindAction("toggleSprint", toggleSprint, false, Enum.KeyCode.LeftShift)
UIS.WindowFocused:connect(windowFocused)
hum.Changed:connect(onJump)
COMMUNITY QUESTION
LoadAnimation requires the Humanoid object to be a descendant of the game object?
1 answer
If the the character resets, its parent is set to nil. You should set the char variable to the new character everytime that happens.
player.CharacterAdded:Connect(function(character)
char = character
end)
1 comment
0
i learned something new today
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Please use code blocks.
How