0, 0, 0
Summary
emphasized text
emphasized text
This text will be blurred
- af
- df
Summary
This text will be hidden
0, 0, 0
emphasized text
emphasized text
This text will be blurred
This text will be hidden
Close should be (0, -90, 0)
, not (0, 0, 0)
.
Ah, I see the issue. Shouldn’t be (0, -90, 0
), lol, my mistake
You’re wanting to return the door to its original orientation whenever you close it. So, set the closing orientation to whatever the door’s orientation is before you open it (seems like it’ll be (0, 0, 0)
).
For some reason when I rotate the model, it might now work on some axis??
Use CFrame.fromAngles(x, y, z)
when you create your target orientation. You’re probably not taking the angle of the door itself into account.
Try making your goal orientations Door.CFrame * CFrame.fromAngles(0, math.rad(value), 0)
.
local open = false
local Hinge = script.Parent.Parent.Hinge
local CLoseGoal = {Orientation = Hinge.CFrame * CFrame.fromAngles(0, math.rad(180), 0)}
local OPenGoal = {Orientation = Hinge.CFrame * CFrame.fromAngles(0, math.rad(0), 0)}
local Tweenservice = game:GetService("TweenService")
local info = TweenInfo.new(
1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.In,
0,
false,
0
)
local Close = Tweenservice:Create(Hinge, info, CLoseGoal)
local Open = Tweenservice:Create(Hinge, info, OPenGoal)
script.Parent.ProximityPrompt.Triggered:Connect(function(hit)
if script.Parent.Parent.Locked.Value == false then
if open == true then
open = false
Close:Play()
script.Parent.SFX:Play()
else
open = true
Open:Play()
script.Parent.SFX:Play()
end
end
end)
i did , then:
attempt to call a nil value
Try changing your target property to CFrame
instead of Orientation
.
i did , same error
This text will be blurred
This text will be blurredo
Try this
local open = false
local Hinge = script.Parent.Parent.Hinge
local CloseGoal = {Orientation = Vector3.new(0, 180, 0)}
local OpenGoal = {Orientation = Vector3.new(0, -90, 0)}
local Tweenservice = game:GetService(“TweenService”)
local info = TweenInfo.new(
1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.In,
0,
false,
0
)
local Close = Tweenservice:Create(Hinge, info, CloseGoal)
local Open = Tweenservice:Create(Hinge, info, OpenGoal)
script.Parent.ProximityPrompt.Triggered:Connect(function(hit)
if script.Parent.Parent.Locked.Value == false then
if open == true then
open = false
Close:Play()
script.Parent.SFX:Play()
else
open = true
Open:Play()
script.Parent.SFX:Play()
end
end
end)
thats not gonna work on all axis
Ok, what I need the door to do is go to the rotation of HingeOpen part, but it does a 180 instead of actually doing it like a normal door. I want to keep it like it was originally just without the 180.
Ah, change fromAngles()
to fromOrientation()
. Turns out fromAngles()
doesn’t exist, LOL
That happens
what are the values of hingeOpen and hingeClose??
What do you mean?
This text will be blurred
I wanna know the values of these values
That’s not nomal, lol
You may need to store the initial CFrame
value of the door before you try tweening it.
I have a similar concept in one of my experiences, and what I did was store a CFrameValue
in the door that has the value of the PrimaryPart
(the hinge’s) CFrame
:
...
-- Storing CFrame value
local CFRAME_VAL = Instance.new("CFrameValue", OBJ)
CFRAME_VAL.Value = OBJ.PrimaryPart.CFrame
-- Making tween
local TWEEN_SERVICE = game:GetService("TweenService")
local TWEEN_INFO = TweenInfo.new(
6.5/5,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false,
0)
-- Using CFrameValue multiplied by opening angle
local TWEEN_PROP = {Value = CFRAME_VAL.Value * CFrame.Angles(0, math.rad(75), 0)}
local TWEEN = TWEEN_SERVICE:Create(CFRAME_VAL, TWEEN_INFO, TWEEN_PROP)
...
In my code, the CFrame
value of the PrimaryPart
’s CFrame
is stored in the CFrameValue
. Then, I use that value to tween the CFrame
of the CFrameValue
object, not the door.
Then, I just use GetPropertyChangedSignal
and listen for when the CFrameValue
changes, and change the pivot of the door itself appropriately with PivotTo()
:
...
-- Somewhere up here tween is played
-- Whenever value of CFrameValue changes, pivot door to new position
CFRAME_VAL:GetPropertyChangedSignal("Value"):Connect(function()
OBJ:PivotTo(CFRAME_VAL.Value)
end)
-- Destroy value once tween is over
TWEEN.Completed:Connect(function()
CFRAME_VAL:Destroy()
end)
...
Sorry for the lack of help. I know model tweening is a particularly finnicky subject.
Okay, everyone i have tried every single method you have suggested to me, and nothing has been working. I’m just going to rewrite a new door. Thanks for all the help, though.