Hey guys. I’m trying to make a rotating cube using CFrame. I got the cube to rotate, but it slides out from under the player. If the cube starts rotating, the player doesn’t rotate with it. Is there a way to make the player move with the cube? I’ve tried using Angular Velocity and Linear Velocity without CFrame but I’ve had many problems with that. Thanks guys!
local TweenService = game:GetService("TweenService")
local timeToRotate = NumberRange.new(7,8)
local rotateRange = NumberRange.new(25)
local tweenStyle = Enum.EasingStyle.Linear
local Model = script.Parent
local CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = script.Parent:GetPrimaryPartCFrame()
CFrameValue.Changed:Connect(function()
Model:SetPrimaryPartCFrame(CFrameValue.Value)
end)
while true do
local info = TweenInfo.new(math.random(timeToRotate.Min,timeToRotate.Max),tweenStyle)
local goal = {Value = Model:GetPrimaryPartCFrame()*CFrame.Angles(
math.rad(math.random(rotateRange.Min,rotateRange.Max)),
math.rad(math.random(rotateRange.Min,rotateRange.Max)),
math.rad(math.random(rotateRange.Min,rotateRange.Max))
)}
local Tween = TweenService:Create(CFrameValue,info,goal)
Tween:Play()
Tween.Completed:Wait()
end