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 » Scripting Helpers
Home Search
 

Re: Does a "Chance of spawning" script exist?

Previous Thread :: Next Thread 
tonyo1 is not online. tonyo1
Joined: 13 Aug 2009
Total Posts: 2059
02 Oct 2013 11:03 PM
Example:
"Model1" has a 40% chance of spawning when a server is created?
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
02 Oct 2013 11:04 PM
Sure. It's possible
Report Abuse
tonyo1 is not online. tonyo1
Joined: 13 Aug 2009
Total Posts: 2059
02 Oct 2013 11:09 PM
But, does such a script exist?
Report Abuse
JoshuaKempfert is not online. JoshuaKempfert
Joined: 16 Feb 2013
Total Posts: 2407
02 Oct 2013 11:11 PM
Your acting like you can't make a script for that.
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
02 Oct 2013 11:13 PM
"But, does such a script exist?"

lol.
Report Abuse
tonyo1 is not online. tonyo1
Joined: 13 Aug 2009
Total Posts: 2059
02 Oct 2013 11:13 PM
Yeah,
Me and scripting don't get along together.
Report Abuse
tonyo1 is not online. tonyo1
Joined: 13 Aug 2009
Total Posts: 2059
02 Oct 2013 11:13 PM
At all.
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
02 Oct 2013 11:13 PM
You're*
Report Abuse
JoshuaKempfert is not online. JoshuaKempfert
Joined: 16 Feb 2013
Total Posts: 2407
02 Oct 2013 11:16 PM
Thank you for the grammar correction Zach. :C
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
02 Oct 2013 11:56 PM
lel sorry i just liek grammar
Report Abuse
JoshuaKempfert is not online. JoshuaKempfert
Joined: 16 Feb 2013
Total Posts: 2407
03 Oct 2013 12:18 AM
umg u i spe;; i wong it suposed to be I gez
Report Abuse
Iterations is not online. Iterations
Joined: 22 Jul 2013
Total Posts: 751
03 Oct 2013 12:43 AM
function X(ch,ma)
local ma = Game:FindFirstChild(ma,true)if not ma then return end
local function cal(m,n) local x,y=m,0; for i = 1, m do if x < n then break end x=x-n; y=y+1; end return y+(x > 0 and x/y or 0) end
if math.random(cal(100,ch))==1 then
ma:clone().Parent=workspace
end
end

X(25, 'Road')
Report Abuse
Iterations is not online. Iterations
Joined: 22 Jul 2013
Total Posts: 751
03 Oct 2013 12:44 AM
forgot something a lot easier

function X(ch,ma)
if math.random(ch/100)==1 then
ma:clone().Parent=workspace
end
end

X(25, 'Road')
Report Abuse
Iterations is not online. Iterations
Joined: 22 Jul 2013
Total Posts: 751
03 Oct 2013 12:45 AM
function X(ch,ma)
local ma = Game:FindFirstChild(ma,true)if not ma then return end
if math.random(ch/100)==1 then
ma:clone().Parent=workspace
end
end

X(25, 'Road')

forgot about finding map
Report Abuse
tonyo1 is not online. tonyo1
Joined: 13 Aug 2009
Total Posts: 2059
03 Oct 2013 01:09 AM
Thanks.
Could you tell me how to edit it please? (like I said above, me and
scripting don't get along together very well)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
03 Oct 2013 01:16 AM
You don't get along because you aren't willing to learn it.
Report Abuse
tonyo1 is not online. tonyo1
Joined: 13 Aug 2009
Total Posts: 2059
03 Oct 2013 01:20 AM
Well, the cavemen taught me scripting but then a giant shark took part of my brain out and I lost my scripting skills forever.

Very emotional story.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
03 Oct 2013 01:22 AM
I prefer my safer way of random:

math.random(100) <= X
Report Abuse
tonyo1 is not online. tonyo1
Joined: 13 Aug 2009
Total Posts: 2059
03 Oct 2013 08:37 AM
bump.
Report Abuse
Marolex is not online. Marolex
Joined: 17 Dec 2012
Total Posts: 1785
03 Oct 2013 08:40 AM
"Knowledge is power" this completely applys in scripting and don't bump when you already received help...
Report Abuse
xXRussianManXx is not online. xXRussianManXx
Joined: 10 Oct 2012
Total Posts: 113
03 Oct 2013 10:38 AM
I actually want to know too. Someone please explain the script above.
Report Abuse
XAXA is not online. XAXA
Joined: 10 Aug 2008
Total Posts: 6315
03 Oct 2013 11:13 AM
local model = game.Lighting.MODEL -- declare your model here
local rand = math.random() -- generates a random number between 0 and 1
if rand < 0.4 then -- if the random number is < 40 (a 40% chance)
local modelClone = model:Clone() -- clones model
modelClone.Parent = Workspace -- parents it to workspace
modelClone:Moveto(Vector3.new(1,1,1)) -- moves it to a specific spot
end -- ends "if"

--Now put these in a function and fire it.
Report Abuse
tonyo1 is not online. tonyo1
Joined: 13 Aug 2009
Total Posts: 2059
03 Oct 2013 11:48 AM
Thank you, XAXA.
Report Abuse
xXRussianManXx is not online. xXRussianManXx
Joined: 10 Oct 2012
Total Posts: 113
03 Oct 2013 11:59 AM
@XAXA: How come I get an error on the first line of code?
Report Abuse
xXRussianManXx is not online. xXRussianManXx
Joined: 10 Oct 2012
Total Posts: 113
03 Oct 2013 12:01 PM
It happens when I put the script into a function.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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