Part.Orientation ignores wait()

Previous Post

How would I tween Part.Orientation?

I haven’t found any good answers/tutorials online on how to tween the orientation of a part:
image
Of course, I know the way to make it constantly rotate, but I am looking for a script/way to make it rotate until it meets a goal. For example, if orientation is 0,0,0 the script would rotate it until it is -90,0,0 then it would stop rotating.

Update: When using this script, the tween ignores the wait and just immediately rotates https://gyazo.com/a76712f73c60b172a50115bd79745038

Here is the script:

local TweenService = game:GetService("TweenService")

local part = script.Parent

local goal = {}
goal.Orientation = Vector3.new(-90, 0, 0)

local goalB = {}
goal.Orientation = Vector3.new(-180, 0, 0)

local tweenInfo = TweenInfo.new(6)

local tween = TweenService:Create(part, tweenInfo, goal)

local tweenB = TweenService:Create(part, tweenInfo, goalB)

if script.Disabled == false then
	tween:Play()
	wait(8)
	tweenB:Play()
end

When using the Create method of the Tween service, allow the final parameter to be a dictionary with key Orientation = Vector3.new(x, y, z).

For example:
game:GetService("TweenService"):Create(PartToTween, TweenInformation, { Orientation = Vector3.new(x, y, z) } );

For more information see this piece of API: TweenService | Documentation - Roblox Creator Hub

2 Likes

Thank you! With this

I was able to make this script:

local TweenService = game:GetService("TweenService")

local part = script.Parent

local goal = {}
goal.Orientation = Vector3.new(-90, 0, 0)

local tweenInfo = TweenInfo.new(1)

local tween = TweenService:Create(part, tweenInfo, goal)

if script.Disabled == false then
	tween:Play()
end

Which worked brilliantly. I’ll try using less keywords when searching for answers next time. Once again, thanks. :grinning:

1 Like

hmm, I have had a bit of a problem though. I am trying to get it so that it rotates, stops for a few seconds, then rotates again. But this is what happens:
https://gyazo.com/a76712f73c60b172a50115bd79745038
It’s supposed to stop at 2 and then rotate again

Here is the script:

local TweenService = game:GetService("TweenService")

local part = script.Parent

local goal = {}
goal.Orientation = Vector3.new(-90, 0, 0)

local goalB = {}
goal.Orientation = Vector3.new(-180, 0, 0)

local tweenInfo = TweenInfo.new(6)

local tween = TweenService:Create(part, tweenInfo, goal)

local tweenB = TweenService:Create(part, tweenInfo, goalB)

if script.Disabled == false then
	tween:Play()
	wait(8)
	tweenB:Play()
end

Any ideas why this won’t work?

Try moving the statement:

local TweenB = TweenService:Create(part, tweenInfo, goalB)

Underneath the wait(8) statement and see if it changes.

I believe it’s because the TweenB tween object is being created from the part’s orientation before it’s get rotated the first time.

I hope this helps,
-Tom :slight_smile:

I tried that, and it didn’t work, so I moved
local goalB = {}
goal.Orientation = Vector3.new(-180, 0, 0)

under the wait too. It sort of half works, because it rotates then stops, but then it doesn’t rotate again.

Going AFK for a bit

which tween do you want to stop, why not use tween:stop()

I just get the error ‘Stop’ is not a valid member of Tween.

what about Tween:Cancel() ???

1 Like

Well, cancel just sort of gets rid of the tween. I found out that :Pause() can stop the tween until you play it again. But still, thanks, I wouldn’t have thought of that if you didn’t mention the cancel part.