Can't rotate platform

I am trying to make a platform randomly rotate in 2 second intervals. Only problem is that for some reason trying to make the platform rotate on the client side never works, but one solution which is server sided does work. I have tried two methods of rotation: AlignOrientation and BodyGyro.

The AlignOrientation makes the platform follow a control part which is tweened to rotate, however this does not update the AlignOrientation when tested on client side.
The second option was BodyGyro, which works, but only on the server side. Trying to move the script and change it to apply client side does not work, with the platform staying still.
I also am using a AlignPosition to keep the part floating, however I don’t think this has any effect on the AlignOrientation/BodyGyro

The other solution is tweening the rotation, but this won’t carry the player with it.

local TweenService = game:GetService("TweenService")

local platform = workspace["Platform"]

local bodyGyro = Instance.new("BodyGyro")
bodyGyro.MaxTorque = Vector3.new(400000, 100, 400000)
bodyGyro.CFrame = platform.CFrame
bodyGyro.P = 1000
bodyGyro.Parent = platform

while wait(2) do
	local rotateChance = math.random(1,5)
	if rotateChance > 3 then
		print("rotate")

		local rotateChoices = {
			{CFrame = platform.CFrame * CFrame.Angles(0,math.rad(45),0)},
			{CFrame = platform.CFrame * CFrame.Angles(0,math.rad(-45),0)}
		}

		local info = TweenInfo.new(
			1.5
		)
		local goal = rotateChoices[math.random(1, #rotateChoices)]

		local tween =  TweenService:Create(bodyGyro, info, goal)
		tween:Play()
	else
		print("norotate")
	end
end

Thanks

1 Like

you could use model:SetPrimaryPartCFrame to set the Orientation of the platform, however: Mind that you can’t tween mode:SetPrimaryPartCFrame

-- script inside serverscriptservice

local platform = workspace.Platform

local attachment = Instance.new("Attachment")
attachment.Parent = platform

local alignOrientation = Instance.new("AlignOrientation")
alignOrientation.Mode = enum.OrientationAlignmentMode.OneAttachment
alignOrientation.Attachment0 = attachment
alignOrientation.MaxTorque = math.huge
alignOrientation.Responsiveness = 10
alignOrientation.Parent = platform

while true do
    alignOrientation.MaxAngularVelocity = math.random(10, 20)
    alignOrientation.CFrame *= CFrame.Angles(0, math.rad(math.random(-45, 45)), 0)
    task.wait(math.random(2, 5))
end