To position your items, you would use vector3.new. Instead of having a value for the position, we need a value of each x, y, and z. Inside of your Mushroomfolder, instead of having stringvalues, or whatever else you have, have multiple folders in the mushroomfolder named spawn1, spawn2, spawn3, etc. Inside each of these folders insert three int values. Name them each x, y, and z. Add the corresponding x, y, and z of your position to each value.
local rs = game:GetService("ReplicatedStorage")
local ss = game:GetService("ServerStorage")
while true do
local values = rs.Spawns:GetChildren()
local value = values[math.random(1,#values)]
local parts = ss.MushroomFolder:GetChildren()
local part = parts[math.random(1,#parts)]:Clone()
local valuex = value.x.Value
local valuey = value.y.Value
local valuez = value.z.Value
part.Handle.Position = Vector3.new(valuex,valuey,valuez)
part.Parent = workspace.tools
wait(10)
end
This would put the value in the x into the x value for the vector 3, and so on.
Edited:
We would probably use math.random
local ss = game:GetService("ServerStorage")
while true do
local parts = ss.MushroomFolder:GetChildren()
local part = parts[math.random(1,#parts)]:Clone()
local valuex = math.random(-100,100)
local valuey = math.random(-100,100)
local valuez = math.random(-100,100)
part.Handle.Position = Vector3.new(valuex,valuey,valuez)
part.Parent = workspace.tools
wait(10)
end
2 comments
But is there any way to generate a completely random position on the map?
Try it now