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 » Scripters
Home Search
 

Re: Item spawning

Previous Thread :: Next Thread 
Seeumliam is not online. Seeumliam
Joined: 06 May 2013
Total Posts: 5662
01 Jan 2015 08:05 PM
What would be the best way in spawning in items, like they do on apocalypse rising? I have been told to pull items out of server storage. But how would I do the chance the item will spawn and teleporting to the location it will spawn?


~ Seeumliam ~
Report Abuse
MrTechn0 is not online. MrTechn0
Joined: 23 Nov 2012
Total Posts: 1252
01 Jan 2015 08:09 PM
teleport and then spawn


"You can't be the Maker and the Owner" -MrTechn0
Report Abuse
Seeumliam is not online. Seeumliam
Joined: 06 May 2013
Total Posts: 5662
01 Jan 2015 08:14 PM
So do something like
game.ServerStorage.Food.Cframe = UDim2.new(0,0,0)
game.ServerStorage.Food.Parent = game.Workspace

If so could I have only one food and be able to have it spawn in 100 different places?


~ Seeumliam ~
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
01 Jan 2015 08:27 PM
something like this


local apple = game.ServerStorage.Apple
while wait(120) do
local c = apple:Clone()
c.Parent = game.workspace
c.CFrame = CFrame.new(math.random(1,400),5,math.random(1,400))
end

just an idea, ive never done something like this before
Report Abuse
Seeumliam is not online. Seeumliam
Joined: 06 May 2013
Total Posts: 5662
01 Jan 2015 08:37 PM
That would allow one apple to spawn I would need them to spawn across the map. I think I figured that part out, now I need to know how to make it have a chance of spawning, like a apple is more likely to spawn then a hand gun. would I just do script.Parent.Text = (math.random(1,1000)) if script.Parent.Text < 100 then spawn this.. if between 100 and 200 then spawn this?


~ Seeumliam ~
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
01 Jan 2015 08:40 PM
function spawnthings()
--script
end


while wait(5) do
local x = math.random(1,100)
local y = math.random(1,100)
if x > 30 and x < 70 and y > 30 and y < 70 then
spawnthings()
end
end

-- like that?
Report Abuse
Seeumliam is not online. Seeumliam
Joined: 06 May 2013
Total Posts: 5662
01 Jan 2015 08:42 PM
Would that be the most efficient way to make the items spawn random? if it is I can use it, I was just wondering if there is other ways that are more efficient.


~ Seeumliam ~
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
01 Jan 2015 08:45 PM
local spawnableItems = { } -- your spawnable items go in here

local function GetSpawnableItem()
return spawnableItems[math.random(#spawnableItems)]
end
Report Abuse
Seeumliam is not online. Seeumliam
Joined: 06 May 2013
Total Posts: 5662
01 Jan 2015 08:49 PM
So if I use that how would I use it? I would put the items in the spot you posted to put them in but how would I control when they spawn and where they spawn?

local spawnableItems = {"food", "water"} -- your spawnable items go in here

local function GetSpawnableItem()
return spawnableItems[math.random(#spawnableItems)]
end


~ Seeumliam ~
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
01 Jan 2015 08:52 PM
You use the other parts of code mentioned in the thread.
Report Abuse
Seeumliam is not online. Seeumliam
Joined: 06 May 2013
Total Posts: 5662
01 Jan 2015 09:02 PM
Like this?


local spawnableItems = {"food", "water"} -- your spawnable items go in here

local function GetSpawnableItem()

return spawnableItems[math.random(#spawnableItems)]
end
if game.Lighting.TimeOfDay == ("14:00:00") then


if #spawnableItems[math.random("food")] then
food1 = game.ServerStorage.Food:Clone()
food1.Name = ("Food1")
food1.Parent = game.Workspace
firstfood = game.Workspace:FindFirstChild("Food1")
firstfood.CFrame = CFrame.new(-107, 0.5, -111)
end
if #spawnableItems[math.random("water")] then
water1 = game.ServerStorage.Water:Clone()
water1.Name = ("Water1")
water1.Parent = game.Workspace
firstwater = game.Workspace:FindFirstChild("Water1")
firstwater.CFrame = CFrame.new(-107, 0.5, -111)
end





end


~ Seeumliam ~
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
01 Jan 2015 09:09 PM
No - you call 'GetSpawnableItem' to get something to spawn.

Something like this:

local SpawnableItem = GetSpawnableItem()
if SpawnableItem == "food" then
-- Spawn food
elseif SpawnableItem == "water" then
-- Spawn water
end
Report Abuse
Seeumliam is not online. Seeumliam
Joined: 06 May 2013
Total Posts: 5662
01 Jan 2015 09:11 PM
Can it spawn multiple items at the same time? also is there a way to make it so one will spawn more than another?


~ Seeumliam ~
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
01 Jan 2015 09:27 PM
probably not a good way but

local c1 = item:Clone()
local c2 = item:Clone()
local c3 = item:Clone()
-- and so on
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
01 Jan 2015 09:30 PM
just give up
Report Abuse
Seeumliam is not online. Seeumliam
Joined: 06 May 2013
Total Posts: 5662
01 Jan 2015 09:32 PM
So like this?

local spawnableItems = {"food", "water"} -- your spawnable items go in here

local function GetSpawnableItem()
if game.Lighting.TimeOfDay == ("14:00:00") then
return spawnableItems[math.random(#spawnableItems)]
end

local SpawnableItem = GetSpawnableItem()

if SpawnableItem == "food" then

food1 = game.ServerStorage.Food:Clone()
food1.Name = ("Food1")
food1.Parent = game.Workspace
firstfood = game.Workspace:FindFirstChild("Food1")
firstfood.CFrame = CFrame.new(-107, 0.5, -111)

elseif SpawnableItem == "water" then
water1 = game.ServerStorage.Water:Clone()
water1.Name = ("Water1")
water1.Parent = game.Workspace
firstwater = game.Workspace:FindFirstChild("Water1")
firstwater.CFrame = CFrame.new(-107, 0.5, -115)

end




end


~ Seeumliam ~
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
01 Jan 2015 09:37 PM
yes like that
Report Abuse
Seeumliam is not online. Seeumliam
Joined: 06 May 2013
Total Posts: 5662
01 Jan 2015 09:38 PM
It doesn't seem to spawn anything in...


~ Seeumliam ~
Report Abuse
Seeumliam is not online. Seeumliam
Joined: 06 May 2013
Total Posts: 5662
01 Jan 2015 09:56 PM
even if I do this, nothing is happening


local spawnableItems = {"food", "water"} -- your spawnable items go in here

local function GetSpawnableItem()
while wait(1) do
if game.Lighting.TimeOfDay == ("14:00:00") then
return spawnableItems[math.random(#spawnableItems)]
end
print ("spawning")
local SpawnableItem = GetSpawnableItem()

if SpawnableItem == "food" then

food1 = game.ServerStorage.Food:Clone()
food1.Name = ("Food1")
food1.Parent = game.Workspace
firstfood = game.Workspace:FindFirstChild("Food1")
firstfood.CFrame = CFrame.new(-107, 0.5, -111)

elseif SpawnableItem == "water" then
water1 = game.ServerStorage.Water:Clone()
water1.Name = ("Water1")
water1.Parent = game.Workspace
firstwater = game.Workspace:FindFirstChild("Water1")
firstwater.CFrame = CFrame.new(-107, 0.5, -115)

end

end


end


~ Seeumliam ~
Report Abuse
Seeumliam is not online. Seeumliam
Joined: 06 May 2013
Total Posts: 5662
02 Jan 2015 12:33 PM
Would I maybe write it like this?


local spawnableItems = {"food", "water"} -- your spawnable items go in here

local function GetSpawnableItem()
print ("spawning")
local SpawnableItem = GetSpawnableItem()

if SpawnableItem == "food" then

food1 = game.ServerStorage.Food:Clone()
food1.Name = ("Food1")
food1.Parent = game.Workspace
firstfood = game.Workspace:FindFirstChild("Food1")
firstfood.CFrame = CFrame.new(-107, 0.5, -111)

elseif SpawnableItem == "water" then
water1 = game.ServerStorage.Water:Clone()
water1.Name = ("Water1")
water1.Parent = game.Workspace
firstwater = game.Workspace:FindFirstChild("Water1")
firstwater.CFrame = CFrame.new(-107, 0.5, -115)

end

end

while wait(1) do
if game.Lighting.TimeOfDay == ("14:00:00") then
return spawnableItems[math.random(#spawnableItems)]
end
end






~ Seeumliam ~
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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