Thank you for taking the time to read my post.
-
What do I want to achieve?
Something simple. I want to achieve rotating a model 45 degrees on its Y-Axis to simulate opening a door through a proximityPrompt connected to a Tween. -
What is the issue?
So far throughout all of the iterations I have provided, nothing has worked.
Here was my original idea: I will include everything in the script once, since its just a few variables, but in future iterations, I will only include what is inside my “goal” table, as I feel it is most relevant.
local TweenService = game:GetService("TweenService")
local prompt = script.Parent
local model = script.Parent.Parent.Parent
local door = model.PrimaryPart
local goal = {
CFrame = CFrame.Angles(0, math.rad(-45), 0),
}
-- Create the Tweens to Open and Close the Door
local openTween = TweenService:Create(door, TweenInfo.new(2), goal)
prompt.Triggered:Connect(function()
print("Tween Play Now")
openTween:Play()
end)
“model” is the door itself, and “door” is the PrimaryPart I am trying to use to rotate the model.
In the above iteration, the only thing in the model that rotates is the primaryPart, not anything else.
Here was my next iteration, attempting to use PivotTo and GetPivot to move the models.
local goal = {
Pivot = model:PivotTo(model:GetPivot() * CFrame.Angles(0, math.rad(-45), 0))
}
-- Create the Tweens to Open and Close the Door
local openTween = TweenService:Create(model, TweenInfo.new(2), goal)
This succeeded in properly orienting the model, except without the use of the Tween. The code inside the table executes without calling the tween whatsoever.
- What solutions have I tried thus far?
Honestly, a lot of documentation research about TweenService and Models. In addition to some YouTube videos and DevForum posts. Most of the tutorial videos and old posts I looked at used deprecated methods like :SetPrimaryPartCFrame in order to move models.
I also saw a potential solution being to un-anchor everything except the primaryPart in the door model, and weld all other parts to that, while using the first method. However, I would really like to avoid that if possible, as there are a lot of other parts in the door.
Any help is appreciated, thanks in advance.