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 |
|
|
| 20 Sep 2015 02:17 PM |
| Scripters subforum can help you. You should also use UserInputService rather than keydown, by the way |
|
|
| Report Abuse |
|