You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to create a tween for opening a door -
What is the issue? Include screenshots / videos if possible!
The Tween keeps pushing the door model downwards -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried setting the door dframe with GetPrimaryPartCFrame local ClosedCFrame = DoorModel:GetPrimaryPartCFrame() and using local OpenCFrame = ClosedCFrame:ToWorldSpace(CFrame.new(-2.5, -4, 0)) * CFrame.Angles(0, 0, math.rad(-45))
But the result was the same, also didn’t find anything close on forum
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local ProximityPrompt = script.Parent
local DoorModel = ProximityPrompt.Parent.Parent.Parent
-- Configuration
local ClosedCFrame = CFrame.new(Vector3.new(-1472.63, -59.061, 1577.069)) * CFrame.Angles(math.rad(-90), 0, math.rad(-90))
local OpenCFrame = CFrame.new(Vector3.new(-1477.948, -59.061, 1574.875)) * CFrame.Angles(math.rad(-90), 0, math.rad(-150))
local IsOpen = false
local TweenService = game:GetService("TweenService")
-- Tween settings
local TweenInfoSettings = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
-- Function to toggle the door state
local function ToggleDoor()
IsOpen = not IsOpen
print(IsOpen)
local targetCFrame = IsOpen and OpenCFrame or ClosedCFrame
DoorModel.Porta.Anchored = false
DoorModel.Porta.CanCollide = false
DoorModel.Union.Anchored = false
-- Tween
local tween = TweenService:Create(DoorModel.PrimaryPart, TweenInfoSettings, { CFrame = targetCFrame })
tween:Play()
tween.Completed:Wait()
DoorModel.Porta.Anchored = true
DoorModel.Porta.CanCollide = true
DoorModel.Union.Anchored = true
end
ProximityPrompt.Triggered:Connect(ToggleDoor)