Tutorial:
how to make a random movement tween rotation.
1. Add a part
2. Rename the part “RandomTweenMovementRotation”
3. Anchor the part
4. Disable the CanCollide
5. Add a script
6. Rename the script “TweenMovementRandomRotation”
Here’s the script
local RandomTweenMovementRotation = "RandomTweenMovementRotation"
local tweenDuration = 2
local easingStyle = Enum.EasingStyle.Linear
local easingDirection = Enum.EasingDirection.Out
local repeatCount = 0
local repeatReverse = false
local repeatDelay = 0
local moveRangeX = {10, 50}
local moveRangeY = {10, 50}
local moveRangeZ = {10, 50}
local rotateRangeX = {0, 360}
local rotateRangeY = {0, 360}
local rotateRangeZ = {0, 360}
local part = game.Workspace:FindFirstChild(RandomTweenMovementRotation)
local tweenInfo = TweenInfo.new(
tweenDuration,
easingStyle,
easingDirection,
repeatCount,
repeatReverse,
repeatDelay
)
local function randomTweenMovement()
while true do
local randomPosition = Vector3.new(
math.random(moveRangeX[1], moveRangeX[2]),
math.random(moveRangeY[1], moveRangeY[2]),
math.random(moveRangeZ[1], moveRangeZ[2])
)
local randomRotation = Vector3.new(
math.random(rotateRangeX[1], rotateRangeX[2]),
math.random(rotateRangeY[1], rotateRangeY[2]),
math.random(rotateRangeZ[1], rotateRangeZ[2])
)
local tween = game:GetService("TweenService"):Create(part, tweenInfo, {
Position = randomPosition,
Rotation = randomRotation
})
tween:Play()
tween.Completed:Wait()
end
end
randomTweenMovement()
Note: You can resize the part whatever you like.
If you are having an issue of bugs while the script is working. Please let me know if you found a bug.
Easing Style:
Linear
Sine
Quad
Quart
Quint
Bounce
Elastic
Exponential
Back
Easing Directions:
In
Out
InOut
You can change the Easing Style and Easing Direction whatever you want.
Thank you for understanding!
That’s all! hope it works.