Hello. I am a Roblox Builder and modeller and have barely any scripting experience so I am looking for some help with an object I would like to rotate.
I am looking to create a teleport “portal” which rotates to attract players eyes using Tween Service or C-frame (not sure what the difference is even).
I have objects in my game that float up and down, but I am looking for this one to rotate in a loop and if possible float up and down at the same time.
I attached an image of the rotational direction i’d like - any help is greatly appreciated!
Would using the AngularVelocity Constraint help you do you think?
If that doesn’t work then you could try the following server script code. Its worked for me before although it’s probably really jank.
local part = -- put the path to your part here
while task.wait(cooldown) do -- cooldown decides rate of spin, play around with it to get a value you like
part.CFrame *= CFrame.Angles(0, increment, 0) -- the increment decides the degree of spin per cooldown
end
setting cooldown to 0.05 and increment to 0.5 in the above code gives this:
this is a script that rotates a part on the Y axis while making it float on the y axis forever
local TweenService = game:GetService("TweenService")
local Part = workspace.Part -- The Part You Will Rotate
TweenService:Create(Part,
TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.In,-1,false),
{ Rotation = Vector3.new(0,180,0) }
):Play() -- the rotation tween
TweenService:Create(Part,
TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.In,-1,true),
{ Position = Part.Position + Vector3.new(0,10,0) }
):Play() -- the float script
replace the Part variable to the instance that you want to rotate and if you want to make it rotate faster change the first argument in the TweenInfo.new
the differance between TweenService and CFrame is that tween service can be used to change any value smoothy like transparency/reflection/position/rotation/cframe
while cframe is used mostly for math like if you want a part to look towards a player you would use CFrame etc
if you want to change how the part rotates/moves change the Enum.EasingStyle.Linear to any other value like Enum.EasingStyle.Sine | Enum.EasingStyle.Bounce etc