generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Game Design
Home Search
 

Animation on Keys (All in one script... help? eheh..)

Previous Thread :: Next Thread 
Myoshin is not online. Myoshin
Joined: 05 Apr 2009
Total Posts: 259
20 Sep 2015 02:06 PM
So how this script works (or at least, how it's supposed to) is when you press a specified key, the player plays the animation and stop playing any previous animation that are under this same script and are also coupled with a key. The script is a local script, is place in the StarterGui, and has 5 children: Initial Values that contain the followed tostring IDs and are named Button1 to Button5.

I think I exploded my brain by thinking too much and I threw too much crap together. Help please? ;-;
__________________________________________________________________________________

wait(.5)
local user=game.Players.LocalPlayer
repeat wait() until user.Character local char=user.Character
local humanoid=char:WaitForChild("Humanoid")

function playanim(id)
if char~=nil and humanoid~=nil then
local id="http://www.roblox.com/Asset?ID="..tostring(id)
local oldanim=char:FindFirstChild("LocalAnimation")
if anim~=nil then
anim:Stop()
end
if oldanim~=nil then
if oldanim.AnimationId==id then
oldanim:Destroy()
return
end
oldanim:Destroy()
end
local animation=Instance.new("Animation",char)
animation.Name="LocalAnimation"
animation.AnimationId=id
anim=humanoid:LoadAnimation(animation)
anim:Play()
end
end

local b1=script.Button1
local b2=script.Button2
local b3=script.Button3
local b4=script.Button4
local b5=script.Button5

Mouse.KeyDown:connect(function(key)
if key == "k" then
playanim(b1.Value)

elseif key == "l" then
playanim(b2.Value)

elseif key == "j" then
playanim(b3.Value)

elseif key == "g" then
playanim(b4.Value)

elseif key == "m" then
playanim(b5.Value)

end

__________________________________________________________________________________

Thanks,

I know I'm still a noob and gradually learning lua. ;n;

Also, hi no-good script vultures!

~Cali all day, baby!
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
20 Sep 2015 02:17 PM
Scripters subforum can help you. You should also use UserInputService rather than keydown, by the way
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image