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