I am trying to make a script witch a part will spawn randomly in a restricted area but i can't seem to do it.
points.Position = Vector3.new(Random<87, 1.5, Random<133)
When the script runs it gives me the following error:
Workspace.Script:3: attempt to compare table with number
Thank you in advance.
Random
returns an object as specified here: https://devforum.roblox.com/t/a-random-feature/64517
You can use math.random()
instead to generate the values you want, it takes a random value from the min parameter to the max parameter and returns it:
Revised Code
local random1 = math.random(-math.huge, 87) local random2 = math.random(-math.huge, 133) points.Position = Vector3.new(random1, 1.5, random2)
math.huge is the same as infinity
I suggest using math.random, you cant perform math on a table, so instead you use the math.random function to satisfy the need to randomize a number.
points.Position = Vector3.new(math.random(0,87), 1.5, math.random(0,133))
You need to set variables for X and Z, which are math.Random. Math.Random will find a random number between two numbers. Looking at the value of x, it will find a random value between 0 and 87.
local x = math.random(0,87) local y = 1.5 local z = math.random(0,133) points.Position = Vector3.new(x,y,z)
I am still learning so if I'm wrong then sorry.