-
What do you want to achieve? I am trying to randomise a variable to randomise the spawn point of a part.
-
What is the issue? math.random() seems to be only working for randomising time and not other random numbers. This script ALWAYS sets randomNum1 to 1 and randomNum2 to 15.
-
What solutions have you tried so far? I have tried to store random numbers in variables first (replaced math.random(1, randomPositionRange), 50, math.random(1, randomPositionRange) with current code). I have also tried to switch between this and Random.new (which gave different numbers but was not random). I have tried to search about this issue online as well and replaced math.randomseed(os.time()) with math.randomseed(time() * tick()) .
Chunk of relevant code:
function spawnPart(randomRange, randomPositionRange, parttospawn)
for i = 1, Random.new():NextInteger(1, randomRange), 1 do
math.randomseed(time() * tick())
wait(math.random(1, 5))
local randomNum1 = math.random(1, randomPositionRange)
local randomNum2 = math.random(1, randomPositionRange)
print(tostring(randomNum1))
print(tostring(randomNum2))
local clonepart = storage[parttospawn]:Clone()
clonepart.Parent = workspace
clonepart.Position = Vector3.new(randomNum1, 50, randomNum2)
end
end
Examples of function that use the code:
function startRain()
spawnPart(30, 100, "Raindrop")
end
function startAcidRain()
spawnPart(30, 100, "AcidRaindrop")
end