#I was trying to make a sprint animation for my game and

4 messages · Page 1 of 1 (latest)

gleaming heath
#

``local NormalWalkSpeed = 14
local SprintSpeed = 25
local CameraEffect = true

local cas = game:GetService("ContextActionService")
local Leftc = Enum.KeyCode.LeftShift
local RightC = Enum.KeyCode.RightShift
local player = game:GetService("Players").LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local Camera = game.Workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
local UIS = game:GetService("UserInputService")

local runAnimationId = "14327553962"

local runAnimation = Instance.new("Animation")
runAnimation.AnimationId = "rbxassetid://" .. runAnimationId

local isRunning = false``

#

``local function handleContext(name, state, input)
local runningAnimationTrack = humanoid:LoadAnimation(runAnimation)

if state == Enum.UserInputState.Begin then
    if CameraEffect == true then
        TweenService:Create(Camera, TweenInfo.new(0.5), {FieldOfView = 50}):Play()
    end
    humanoid.WalkSpeed = SprintSpeed

    runningAnimationTrack:Play()
    isRunning = true
else
    if CameraEffect == true then
        TweenService:Create(Camera, TweenInfo.new(0.5), {FieldOfView = 70}):Play()
    end
    humanoid.WalkSpeed = NormalWalkSpeed

    runningAnimationTrack:Stop()
    isRunning = false
end

end

cas:BindAction("Sprint", handleContext, false, Leftc, RightC) -- Changed to false for the initial state
cas:SetPosition("Sprint", UDim2.new(.2, 0, .5, 0))
cas:SetTitle("Sprint", "Sprint")
cas:GetButton("Sprint").Size = UDim2.new(.3, 0, .3, 0)

UIS.InputEnded:Connect(function(key, gameProcessed)
if gameProcessed then return end
if key.KeyCode == Enum.KeyCode.LeftShift then
if CameraEffect == true then
TweenService:Create(Camera, TweenInfo.new(0.5), {FieldOfView = 70}):Play()
end
humanoid.WalkSpeed = NormalWalkSpeed

    if isRunning then
        humanoid:LoadAnimation(runAnimation):Stop()
        isRunning = false
    end
end

end)``

#

Heres my script

#

pls helpagony