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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|
| |
|
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 |
|
|
| |
|
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
|
  |
| 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
|
  |
| 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 |
|
|