Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

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

1 answer

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

1 comment

0

Please rep if you like the answer

This discussion is preserved as it was. New answers, comments, and votes are closed.