How would you detect terrain?

so thru sum help i made a script that places parts around ur character in a circle but i want to place them on the terrain if that makes sense…?

how would you detect terrain for doing something like that; if that’s possible that is…? i appreciate any help ty!

image

1 Like

Shoot a raycast from around +10 studs above the blocks downwards, then put the blocks to where the raycast lands

[Raycasting | Documentation - Roblox Creator Hub]

2 Likes

raycast can include terrain, create a raycast facing down from the part and make sure terrain is included in the raycast and set the parts position to the hit poisition + half of the size of the object.

not tested, but this should would

local part = script.Parent
local origin = spawnPosition + Vector3.new(0,10,0)
local rayDirection = Vector3.new(0,-100,0) -- 100 is just the range of the raycast
local raycastParams = RaycastParams.new()



local raycast = workspace:RayCast(origin, direction, raycastParams)

if raycast then
   part.Position = raycast.Position + Vector3.new(0,part.Size.Y/2,0)
end
2 Likes

would he better do it on client or server side? because probably hackers would be exploiting onc client side but on the server side how could he do it?

1 Like
1 Like

hey Matcha,
thanks a million for your help and for the links; i read over them all and got it. thank you so much!!

1 Like

hey builder,
thanks a million for your help mate. i got it straight away. tysm :slight_smile:

1 Like

this method isnt 100% efficient no?

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