You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
I’m trying to make a function that will give me a random floor, using raycasts. -
What is the issue?
The function returns as nil.
-
What solutions have you tried so far?
I added the “repeat untill” and i checked the forums
We are assuming that argument 1 and 2 are both nil.
function module.GetRandomFloor(mode, range)
-- define variables
local vector = nil
-- fixed stats(?)
local direction = Vector3.new(0, -90, 0)
-- autofil
if range == nil then range = 64 end
if mode == nil then mode = 0 end
-- modes
local ray = nil
repeat
if mode == 0 then
-- true random
vector = Vector3.new(math.random(-range,range),math.random(-range,range),math.random(-range,range))
end
local ray = workspace:Raycast(vector,direction)
print("Casting ray")
until ray ~= nil
print("Ray sucess")
return {ray.Position, ray.Distance}
-- cast ray
-- return
end