I have an model, and I need to get a random rotation,
Local model = --whatever model local cFrame = CFrame.new(0,0,0)--the CFrame is obtained through other calculations local randonRotation = math.rad(math.random(1, 360)) --This is an imaginary scenario cFrame:AddRotation(randonRotation , 0, 0) model :SetPrimaryPartCFrame (cFrame)
so the model is going to have a random rotation in X axis, but I don't know how to add the rotation.
Any help would be appreciated.
You can use the CFrame.Angles
constructor to add rotation to your CFrame :)
local model local _CFrame = CFrame.new(0,0,0) --rotated on the 'x' axis local randomRotation = CFrame.Angles(math.rad(math.random(1, 360)),0,0) local rotatedCFrame = _CFrame * randomRotation model:SetPrimaryPartCFrame(rotatedCFrame)