Actual Random Numbers

How would i go about a random number every time?
im making a bowling system and using math.random to decide where the pins fly
The problem is it picks 1 random number i need a random number for x, y, z and for the other 10 pins

workspace.ActiveBalls.ChildAdded:Connect(function(ball)
	ball.Touched:Connect(function(toutcher)
		if toutcher.Name == "Pin1" then
			toutcher.CanCollide = false
			toutcher.CanTouch = false	
			toutcher.Velocity = Vector3.new(math.random(100,200), math.random(100,200), math.random(100,200))
		end
		if toutcher.Name == "Pin2" then
			toutcher.CanCollide = false
			toutcher.CanTouch = false	
			toutcher.Velocity = Vector3.new(math.random(100,200), math.random(100,200), math.random(100,200))
		end
		if toutcher.Name == "Pin3" then
			toutcher.CanCollide = false
			toutcher.CanTouch = false	
			toutcher.Velocity = Vector3.new(math.random(100,200), math.random(100,200), math.random(100,200))
		end
		if toutcher.Name == "Pin4" then
			toutcher.CanCollide = false
			toutcher.CanTouch = false	
			toutcher.Velocity = Vector3.new(math.random(100,200), math.random(100,200), math.random(100,200))
		end
		if toutcher.Name == "Pin5" then
			toutcher.CanCollide = false
			toutcher.CanTouch = false	
			toutcher.Velocity = Vector3.new(math.random(100,200), math.random(100,200), math.random(100,200))
		end
		if toutcher.Name == "Pin6" then
			toutcher.CanCollide = false
			toutcher.CanTouch = false	
			toutcher.Velocity = Vector3.new(math.random(100,200), math.random(100,200), math.random(100,200))
		end
		if toutcher.Name == "Pin7" then
			toutcher.CanCollide = false
			toutcher.CanTouch = false	
			toutcher.Velocity = Vector3.new(math.random(100,200), math.random(100,200), math.random(100,200))
		end
		if toutcher.Name == "Pin8" then
			toutcher.CanCollide = false
			toutcher.CanTouch = false	
			toutcher.Velocity = Vector3.new(math.random(100,200), math.random(100,200), math.random(100,200))
		end
		if toutcher.Name == "Pin9" then
			toutcher.CanCollide = false
			toutcher.CanTouch = false	
			toutcher.Velocity = Vector3.new(math.random(100,200), math.random(100,200), math.random(100,200))
		end
		if toutcher.Name == "Pin10" then
			toutcher.CanCollide = false
			toutcher.CanTouch = false	
			toutcher.Velocity = Vector3.new(math.random(100,200), math.random(100,200), math.random(100,200))
		end
	end)
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

Try making a function every time you need a random number. It should be something like this:

function randomNumber()
    local number = math.random(100, 200)
    return number
end

while wait(0.01) do
    local number = randomNumber()
    print(number)
end
1 Like

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