Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Hi? What i need to add to put animation while running? TYIA [closed]

Asked by 6 years ago
Edited 6 years ago
local mouse = game.Players.LocalPlayer:GetMouse()
local running = false

function getTool()  
    for _, kid in ipairs(script.Parent:GetChildren()) do
        if kid.className == "Tool" then return kid end
    end
    return nil
end


mouse.KeyDown:connect(function (key) 
    key = string.lower(key)
    if string.byte(key) == 48 then
        running = true
        local keyConnection = mouse.KeyUp:connect(function (key)
            if string.byte(key) == 48 then
                running = false
            end
        end)
        for i = 1,5 do
            game.Workspace.CurrentCamera.FieldOfView = (70+(i*2))
            wait()
        end
        game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 15
        repeat wait () until running == false
        keyConnection:disconnect()
        game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 10
        for i = 1,5 do
            game.Workspace.CurrentCamera.FieldOfView = (80-(i*2))
            wait()

        end
    end
end)
0
free model GingeyLol 338 — 6y

Closed as Not Constructive by GingeyLol, User#20388, and Programical

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 6 years ago
local Animation = Instance.new('Animation')
local Track = nil 

game.Players.LocalPlayer.Character.Humanoid.Running:connect(function(speed)
    if speed > 0 then 
        print('running')
        Animation.Animation.Id = --your id here
        Track = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(Animation)
        Track:Play()
    else
        print('idle')
    end
end)
Ad