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

How to make it when you press shift it does a running animaton?

Asked by 9 years ago

so this is my script of /e customanimation

setupCheck = game.ServerStorage:findFirstChild("Animations") if setupCheck == nil then error(script.Name .. " hasn't been setup!", 0) end -- Yes I really just did that

anims = game.ServerStorage.Animations:GetChildren()

game.Players.PlayerAdded:connect(function(player) function playAnimation(name) for i, anim in ipairs(anims) do if anim.Name:lower() == name:lower() then local b = player.Character.Humanoid:LoadAnimation(anim) b:Play() print(player.Name .. " played animation: " .. anim.Name) end end end

player.Chatted:connect(function(message)
    if message:sub(1, 3) == "/e " then
        local a = playAnimation(message:sub(4))
    end
end)

end)

and i want it so that if you press shift to run it plays and when you stop running it stops playing

can someone help me or send me a script

0
Thanks before you gave me an answer i made it and it works perfectly when i press Q the run animation starts perfectly and stops perfectly its like the script from r2d check it out http://www.roblox.com/games/228463339/Animation-Test UnitedKingdomRNS -4 — 9y

1 answer

Log in to vote
2
Answered by 9 years ago

Using user input service is a good idea for a script like this then getting the tick() time fi you want to let them have a certian time limit before they arn't able to run again if they use it all up but to play an animation you need to make a animation then load it into the humanoids character like this

In a LocalScript with animation named "Animation" in its directory

local animation=script.Parent.Animation
local plyr=game.Players.LocalPlayer
function LoadAnimation(anim)
    plyr.Character.Humanoid:LoadAnimation(anim)
end
function PlayAnimation(animtrack)
    animtrack:Play()
end
function StopAnimation(animtrack)
    animtrack:Stop()
end

for more advance documentation I would look at the api on animationtracks which are loaded when you use the load animation function on humanoids here

0
Please rep if you like the answer nstrike159 15 — 9y
Ad

Answer this question