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
 

Re: I Need Help With a Script

Previous Thread :: Next Thread 
tornadozebra is not online. tornadozebra
Joined: 02 Oct 2011
Total Posts: 316
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 is not online. 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
tornadozebra is not online. tornadozebra
Joined: 02 Oct 2011
Total Posts: 316
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 is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
19 Jan 2015 06:21 PM
um math.random only takes 2 arguments...
Report Abuse
tornadozebra is not online. tornadozebra
Joined: 02 Oct 2011
Total Posts: 316
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 is not online. 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
tornadozebra is not online. tornadozebra
Joined: 02 Oct 2011
Total Posts: 316
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
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