TweenService doesn't tween according to the PivotPoint

So I’ve made a tween script to change the orientation of a door. I thought that the rotation should happen according to the position of the PivotPoint. Which is located here:

Screenshot (16)

But the tween goes out like this:

robloxapp-20240201-2013053.wmv (1.1 MB)

Here’s the script if it could have connection with the problem:

local main = script.Parent.Parent
local prompt = script.Parent
local TweenService = game:GetService("TweenService")
local SoundService = game:GetService("SoundService")
local Sound = SoundService.PostalSounds.Sound
local sound_length = 0.85
local tweening_info = TweenInfo.new(0.8, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)

local goal1 = {}
goal1.CFrame = main.CFrame * CFrame.Angles(0, math.rad(135), 0)

local goal2 = {}
goal2.CFrame = main.CFrame * CFrame.Angles(0, math.rad(45), 0)

local tween_1 = TweenService:Create(main, tweening_info, goal1)
local tween_2 = TweenService:Create(main, tweening_info, goal2)

local is_open = false
prompt.Triggered:Connect(function(player)
	if is_open == false then
		prompt.Enabled = false
		tween_1:Play()
		Sound:Play()
		task.wait(sound_length)
		Sound:Pause()
		prompt.Enabled = true
	elseif is_open == true then
		prompt.Enabled = false
		tween_2:Play()
		Sound:Resume()
		prompt.Enabled = true
	end
	is_open = not is_open
end)

Thats right, Pivot points and the actual Parts CFrame its the different things
you have to manually lerp the pivot using :PivotTo(CFrame)

So I have to do something like this?

local CFrame_val = CFrame.new(0,5,0)
local new_CFrame = part.CFrame * part:PivotTo(CFrame_val)

Correct me if I’m wrong

Or you could just have an Anchored ‘hinge’ Part where you want the door to rotate at and tween the ‘hinge’ angle.
Weld your Unanchored door to the ‘hinge’ and it’ll work just fine.

This only adds 1 part and 1 weld to each door. Even if you have thousands of doors it probably won’t cause any lag.

1 Like

Um I dont think that’s supposed to happen…

robloxapp-20240202-1335376.wmv (1.3 MB)

Where is your hinge Part in that. It’s supposed to be at the location your PivotPoint was at.
Are you sure the door has a WeldConstraint to the hinge Part? It looks like it has a HingeConstraint or BallSocketConstraint joining it.

Another thing, you don’t need the elseif is_open == true then statement, just make it else since the first if statement already covers one condition so you don’t need to repeat it again for the opposite condition.

I’ve done exactly what you’ve said but the door this time is completely frozen. I don’t know why I a weld part that acts as a hinge could fix this issue. It’s meant to glue the part and preventing it from moving, a thing I’m not searching for

You anchor the hinge part that is tweened.
You Weld the unanchored door to the hinge part.
Make sure you don’t have the door welded to anything other than the hinge. You can go to the Model tab in Studio, look in the Constraints tools, and choose “show welds” to let you know if you have WeldConstraints properly placed. If you select the green or gray weld line it’ll also highlight the 2 connected Parts.
When the hinge part tweens and rotates on its axis, the part (or parts) that are welded to it rotate with it.

Watch this tutorial: https://www.youtube.com/watch?v=9dw9i2pcxaU

1 Like

Thank you for your patience, now it’s actually working

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.