|
| 19 Jan 2015 06:02 PM |
What I want to do, is when you click on the Attack button, it randomly picks from 1-0, and then subtracts it from the Opponets health. I have this much:
function onclick() local attack = math.random(0,1,1) if attack == 0 then script.Parent.Parent.Health.Value = 3 print "Attack Failed" end if attack == 1 then script.Parent.Parent.Health.Value = 2 print "Attack Done" end end script.Parent.MouseButton1Click:connect(onclick)
|
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 19 Jan 2015 06:17 PM |
"local attack = math.random(0,1,1)"
someone use for loops a bit much?
local attack = math.random(0,1) |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2015 06:19 PM |
I am basing this off of a different game, and in that game, it is like local attack = math.random(0,0,0,0,0,0,0,0,0,0,1) So I want to give this a good chance of hitting. |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 19 Jan 2015 06:21 PM |
| um math.random only takes 2 arguments... |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2015 06:23 PM |
Alright, ill put it back to (0,1) is there a way to subtract from values? |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 19 Jan 2015 06:27 PM |
you mean like this?
prob1 = 3 prob2 = 2
answer = prob1 - prob2
print(asnwer) --> 1 |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2015 06:47 PM |
so like:
---------------------------------------------------- function onclick() local Prob1 = script.Parent.Parent.Health.Value local prob2 = math.random(0,1)
answer = prob1 - prob2 Prob1 = answer script.Parent.Parent.Health.Text = answer print answer end end script.Parent.MouseButton1Click:connect(onclick)
------------------------------------------------------- Would this work?
|
|
|
| Report Abuse |
|
|