I wanted to move a Part in random positions. The platform that I made for the part to move has 2 points on the other 2 corners.
(Upper point is PointA, the lower point is PointB, and the blue part in the middle is the Part.)
I get a error like invalid argument #2 to 'random' (interval is empty) and I know what it means but anyway to fix it?
Script:
local pointA = game.Workspace:WaitForChild("PointA")
local pointB = game.Workspace:WaitForChild("PointB")
local main = game.Workspace:WaitForChild("Main")
while wait(1) do
local aX = pointA.Position.X
local bX = pointB.Position.X
local aZ = pointA.Position.Z
local bZ = pointB.Position.Z
main.Position = Vector3.new(math.random(aX, bX), 2, math.random(aZ, bZ))
end
I edited it try it again, It shouldn’t go off platform now, unless you already tried it and I assume your current problem is the Part somewhat being outside the platform?
Incase you get PTSD about it, this will completely stop that and make sure its 100% Inside the zone, thought if the Part is bigger than the zone then I can’t guarantee that 100%.