|
| 14 Jul 2014 06:45 PM |
So, I need my Tool to randomly play one of the 4 animations. But there is one which needs a special touch to it, and I don't know how to make if statement that tracks if the animation is the animation that needs the special touch.
This is what I got so far:
AnimTable = {Tool:WaitForChild("Attack1"), Tool:WaitForChild("Attack2"), Tool:WaitForChild("Attack3"), Tool:WaitForChild("Attack4")} swoosh = Handle:WaitForChild("Swoosh") -- This is actually in Handle
function lmc() if Tool.Enabled == false then return end attack = plr:WaitForChild("Humanoid"):LoadAnimation(AnimTable[math.random(1,#AnimTable)]) attack:Play() Tool.Enabled=false wait(0.4) swoosh:Play() wait(0.45) Tool.Enabled=true end
Tool.Activated:connect(lmc) |
|
|
| Report Abuse |
|
|
LetUsGame
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 199 |
|
|
| 14 Jul 2014 06:46 PM |
local chosen = math.random(1,#AnimTable) if chosen== 2 then --stuff end attack = plr:WaitForChild("Humanoid"):LoadAnimation(AnimTable[math.random(1,#AnimTable)]) |
|
|
| Report Abuse |
|
|
LetUsGame
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 199 |
|
|
| 14 Jul 2014 06:46 PM |
I'm just kidding:
local chosen = math.random(1,#AnimTable) if chosen== 2 then --stuff end attack = plr:WaitForChild("Humanoid"):LoadAnimation(AnimTable[chosen]) |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2014 06:55 PM |
| What does the 2 stand for? |
|
|
| Report Abuse |
|
|
BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
|
| 14 Jul 2014 07:00 PM |
AnimTable = {Tool:WaitForChild("Attack1"), Tool:WaitForChild("Attack2"), Tool:WaitForChild("Attack3"), Tool:WaitForChild("Attack4")}
You have 4 animations so '2' would be Attack2. |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2014 07:01 PM |
chosen = AnimTable[math.random(1,#AnimTable)] attack = plr:WaitForChild("Humanoid"):LoadAnimation(chosen)
|
|
|
| Report Abuse |
|
|
LetUsGame
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 199 |
|
|
| 14 Jul 2014 07:01 PM |
| It's arbitrary; it can be any number. If it's 2, the 2nd attack in the table is the one that's chosen. |
|
|
| Report Abuse |
|
|
| |
|
|
| 14 Jul 2014 07:34 PM |
So how would this be worked out in my script? Maybe that way I can learn it better.
function lmc() if Tool.Enabled == false then return end attack = plr:WaitForChild("Humanoid"):LoadAnimation(AnimTable[math.random(1,#AnimTable)]) attack:Play() Tool.Enabled=false wait(0.4) swoosh:Play() wait(0.45) Tool.Enabled=true end |
|
|
| Report Abuse |
|
|
robotmega
|
  |
| Joined: 16 May 2009 |
| Total Posts: 14084 |
|
|
| 14 Jul 2014 08:00 PM |
| I'm 15, and an advanced scripter and builder. I try to keep up with my messages, but i cannot promise a respond. If you really want me to see your message, talk to me on |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2014 08:59 PM |
| Nice respond. Also, if you're trying to qoute the fact I stated I'm an advanced scripter, it is true. I haven't took an in-depth look in animations. Advanced scripters don't know everything, too. |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2014 09:07 PM |
| In my opinion, advanced scripters aren't ment to know everything about scripting. Some focus on certain things and get specialized in that. Some get a bit of everything. Just saying my opinion. |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2014 09:13 PM |
This isn't advanced and you've already been told what to do. What you're doing: Table[math.random(#Table)]
What you need to do: RandomIndex = math.random(#Table) if RandomIndex = GENERICNUMBER then --script when it's a certain index end Table[RandomIndex] -- Do whatever you're doing with your table |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2014 01:06 AM |
@Above
It isn't advanced, indeed. It is simply... Hard to understand, because I didn't use math.random a lot, so now I don't have a lot of comprehension about how it works. (well, what you can do with it). |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2014 01:09 AM |
Here is how I understand it:
function lmc() if Tool.Enabled == false then return end attack = plr:WaitForChild("Humanoid"):LoadAnimation(AnimTable[math.random(1,#AnimTable)]) attack:Play() if attack == 3 then print("Special animation") else print("Regular animation") end end |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2014 11:06 AM |
function lmc() if Tool.Enabled == false then return end num = math.random(1,#AnimTable) attack = plr:WaitForChild("Humanoid"):LoadAnimation(AnimTable[num]) attack:Play() if num == 3 then print("Special animation") else print("Regular animation") end end |
|
|
| Report Abuse |
|
|