It’s hard to explain, but I want to make a script grab a random position around a origin point and limit it to a few parts, like have a max of 3-5 parts that it chooses to keep screenshots at bottom of post
The issue is I tried multiple scripts and ways (overlap params, raycasting, vectors) nothing seemed to have worked.
I have no scripts to show because my Roblox Studio decided to not save when I saved so I sadly can’t show you my current script. I AM NOT ASKING FOR YOU TO WRITE ME A SCRIPT, I AM ASKING FOR A SIMPLE LINE OF CODE OR MORE TO GET IT
I have tried the developer forum, scripting helpers, other scripting languages like c++ examples and putting them to a LuaU format but no videos existed for my topic.
There isn’t much more detail I can put here but heres the images of some examples:
(I also need a radius of around 10-25 studs so the player wont just go across the map.)
this script shoots rays into different directions and setting them there:
local numRays = 10 --Not parts, if ray doesn't hit, no part spawned
local position = Vector3.new(0, 10, 0) --Change this to the position you want the rays to originate from
local rayLength = 32 --Studs
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist --We add nothing, so it hits everything, but you can add player's character
for i = 1, numRays do
local direction = CFrame.Angles(math.rad(math.random(360)), math.rad(math.random(360)), math.rad(math.random(360))).LookVector
local ray = workspace:Raycast(position, direction * rayLength, params)
if ray then
local part = Instance.new("Part")
part.Anchored = true
part.Position = ray.Position+ray.Normal*part.Size.Y
--You can change color etc. Good luck
end
end