Whatever This is called

So I’m not super good at scripting, still really new to it. But long story short I’m trying to make a system that takes (x1, x2) and (y1, y2) and gives out a random position in between them.
image
This is what I have so far, don’t judge me too hard but I’m getting an error and don’t know why.

ServerScriptService.Script:12: invalid argument #2 to ‘random’ (interval is empty)

1 Like

It’s because math.random(a,b) gives an error when a > b, so you have to check if it is larger.

2 Likes

y2 has a position argument on the x axis.

Otherwise, this should help.

-107.5 -92.5 0.5 0.5
x1, x2 - y1, y2

I agree with @calvin_coco

Try this maybe?

if x > y then
print(math.random(y, x))
else
print(math.random(x,y))
end
1 Like

Trying to take x1, x2 and y1, y2 to pick a random point on my set 2d region

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.