How can i like make a random part spawning but with 2 parts there and i take the position of the 2 parts and it randomly spawns in the radius in it like this:
This should work:
local newPart = Instance.new("Part")
newPart.Parent = workspace
newPart.Position = Vector3.new(math.random(here the xPos of one of the part, and here the position of the other), math.random(here the yPos of one of the part, and here the position of the other), math.random(here the zPos of one of the part, and here the position of the other)
in Vector3.new(math.random(here the xPos of A point, xPos of B point), math.random(here the yPos of A point, yPos of B point), math.random(here the zPos of A point, zPos of B point))
nope
while wait() do
local tmp = script.Part:Clone()
local x1 = script.Parent.one.Position.X
local x2 = script.Parent.two.Position.X
local z1 = script.Parent.one.Position.Z
local z2 = script.Parent.two.Position.Z
tmp.Position = Vector3.new(math.random(x2, x1), 0.987, math.random(z2, z1))
wait(5)
end
Do not insert the letters (x/y/z) they aren’t needed, just the numbers.
and how i get the numbers then…
Vector3.new(math.random(x1, x2), 0.987, math.random(z1, z2))
Try this instead. The first parameter of math.random has to be less than the second parameter. It could be that x2 and z2 are greater than x1 and z1, so they need to go second.
part.Position = Vector3.new(math.random(script.Parent.Pos1.Position.X, script.Parent.Pos2.Position.X), 0.987, math.random(script.Parent.Pos2.Position.Z, script.Parent.Pos1.Position.Z))
In case of a negative number you must insert before the greater and then the smaller; example: -50, -40 you must write math.random(-50, -40)