Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I'm not the best at positioning, how do you make objects spawn in a radius?

Asked by 6 years ago

If I have a position of -222.364, 3.75, 1082.273 and size of 937, 0.5, 1026.11. How do I make it so that objects will spawn within this radius? This is a platform

local Orange = game.ServerStorage:WaitForChild('Orange')
math.randomseed(tick())
for _ = 1, 500000 do
    local NewOrange = Orange:Clone()
    NewOrange.CFrame = CFrame.new(math.random(-2048, 2048),math.random(20, 50),math.random(-2480,2048))
    wait(1)
    NewOrange.Parent = game.Workspace:WaitForChild('Oranges')
end

Thank you for any support or feed back

-- your Orange, BlackOrange3343.

1 answer

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago

If you are looking for a part to spawn anywhere inside the brick, you'd use this

local Orange = game.ServerStorage:WaitForChild('Orange')
math.randomseed(tick())

local pos = Vector3.new(-222.364, 3.75, 1082.273) -- You can replace this with obj.Position
local size = Vector3.new(937, 0.5, 1026.11)

local halfsize = size / 2

for _ = 1, 500000 do
    local NewOrange = Orange:Clone()
    NewOrange.CFrame = CFrame.new(math.random(pos.X-halfsize.X, pos.X+halfsize.X),math.random(pos.Y-halfsize.Y,pos.Y+halfsize.Y),math.random(pos.Z-halfsize.Z,pos.Z+halfsize.Z))
    wait(1)
    NewOrange.Parent = game.Workspace:WaitForChild('Oranges')
end

0
Thanks worked and learned. BlackOrange3343 2676 — 6y
Ad

Answer this question