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.
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.
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)
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.
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