So I am currently trying to figure out how I could get models or parts in a random rotation. Is this even possible?
If so, I want the models and parts to face in random directions(Foward, Left, Right) but i don’t know how i could do this.
Here is a part of the code:
elseif event == 4 then
local Wall = game.ServerStorage.Events.Wall:Clone()
local position = Vector3.new(math.random(-114, 12),8.056,math.random(-124, 33))
local cf = CFrame.new(position)
Wall:PivotTo(cf)
Wall.Parent = workspace.EventFolder
I do know how to spawn them in random positions but I want the to face a certain direction too, how can I do this?
Also you can rotate it by using CFrame.lookat()
local randpos = part.Position + Vector3.new(math.random(0,5),math.random(0,5),math.random(0,5))
part.CFrame = CFrame.lookat(part.Position,randpos)
If you want the part to face another part you can use this
part.CFrame = CFrame.lookat(part.Position,anotherpart.Position)
Also you can make it easier just set primary part
And then
rotation = CFrame.Angles(math.rad(math.random(0,90)), math.rad(math.random(0,90)), math.rad(math.random(0,90)))