Tween on a pivot

I’m trying to make a door tween to a side once the player hits it.

But when the player touches the door the tween just goes through the wall into the spot, It is not pivoted on the “hinges”

Is it possible to make a tween pivot on a certain point?

Any help is appreciated!

2 Likes

Would it be possible to make a video showing what your issue is?

1 Like

I haven’t made it yet, but I’ve had this problem in past games. (I sadly can’t record it)

I’m trying to make it so that once the player touches the door with the .Touched() function, the door will swing to the opposite side.

But once you make a tween with the position where you want the door to end up, it doesn’t go “around the wall” it just goes straight to the end position. I want the pivot to be like irl doors, at the hinges, but I’m not sure if you can do that with tweening.

Hope this helped, it’s kind of hard to explain.

1 Like

Well I can only think of one thing, that is to edit the part (door) or whatever is your primary part using the edit pivot tool. This is found in the model tab at the top under the pivot section. Adjust the pivot to where the hinge is and then run the game to see if it works.

1 Like

Yes, that is the result that I want, unfortunately, it doesn’t work. I’m wondering if there is a way to script that.

1 Like

I’m working on making a script to see if it works.

1 Like

When I try to script it, the pivot position seems to be ignored. As a work around, I used the position and orientation values when the door is opened and closed and then tweened those. I will have to do research if you can actually tween the rotation based on the hinge position.

This is technically not what you want, but maybe the code will do you some good.

local tS = game:GetService("TweenService")

local door = script.Parent
local doorOpen = false

door.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	
	if humanoid and not doorOpen then
		local tweenInfo = TweenInfo.new(1)
		local goal = {Position = Vector3.new(57.5, 4.5, -87), Orientation = Vector3.new(0, -90, 0)}
		tS:Create(door,tweenInfo,goal):Play()
		wait(1)
		doorOpen = true
	
		else if humanoid and doorOpen then
			local tweenInfo = TweenInfo.new(1)
			local goal = {Position = Vector3.new(59, 4.5, -89.5), Orientation = Vector3.new(0, 0, 0)}
			tS:Create(door,tweenInfo,goal):Play()
			wait(1)
			doorOpen = false
		end
	end
end)

Thanks for your time and effort, but unfortunately this is not what I need.

I appreciate your help!

you could make the door a model and then have a primary part that is located where the hinges should be and tween the primary part’s rotation. Seems like the easiest work around for me.

How do I tween a model though?

You shouldn’t directly change the CFrame and use a Weld instead, and apply an offset to either C0 or C1 and only tween one of them.

No problem, I’ll come back here if I find anything useful.

This can be done, but can you take a screenshot or draw something to show what you want the door to look like, and where you want it to pivot on door and wall

You can actually tween a part’s position to another part’s position

can this help?
https://create.roblox.com/marketplace/asset/6892515423?viewFromStudio=true&keyword=proximity%20prompt%20door&searchId=9834C0A3-3947-4C8E-961E-3A479100A96D

(its a model)

1 Like

Just add another part to the door to be tweened and weld the actual door to that part.


I couldn’t put in well in words so there’s an image.

Just rotate the added part and the actual door(Red) should follow while pivoting the added part.

1 Like

Sorry for the late response but this worked! (with a few scripts)

Thank you guys for your help!

2 Likes

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