# Untitled

unknown

lua

a year ago

893 B

4

Indexable

Never

^{}

local midPoint = (startPoint + endPoint)/2 -- Get the midpoint position local dir = (endPoint - startPoint).Unit -- Get the direction vector(to - from) local cf = CFrame.lookAt(midPoint,midPoint + dir) -- Get the CFrame that looks at that direction vector and is centered at midpoint local range = 20 -- range in studs local RNG = Random.new() --[[ CFrame.rightVector describes the vector that points to the right of a CFrame So the left most point we can have is midPoint - CFrame.rightVector * range And the right most point we can have is the opposite Lerp lerps a vector from a to b based on an alpha(0-1) So we then lerp from the left to right most by a random value between 0 and 1, to find a random position between the left and right most points ]] local randomPoint = (midPoint - cf.rightVector * range):Lerp(midPoint + cf.rightVector * range,RNG:NextNumber())