Making a door open through pulling a lever, The lever tweening works but the gate when it opens it should go to the certain y axis value but it just goes really far to a different spot without me changing it’s x or z axis and it doesn’t even go to the y axis I specified it to go to, Any idea? Script:
local Sound = script.Parent.Sound
local Hinge = script.Parent.Parent.Parent.PrimaryPart
local MetalBar2 = game.Workspace.MetalBar2.PrimaryPart
local Tween = game:GetService("TweenService")
local Info1 = TweenInfo.new(
1,
Enum.EasingStyle.Bounce,
Enum.EasingDirection.Out,
0,
false
)
local Info = TweenInfo.new(
20,
Enum.EasingStyle.Bounce,
Enum.EasingDirection.Out,
0,
false
)
local OpeningTable1 = {
CFrame = MetalBar2.CFrame * CFrame.new(MetalBar2.Position.X, -51.437, MetalBar2.Position.Z)
}
local OpeningTable2 = {
CFrame = Hinge.CFrame * CFrame.Angles(math.rad(-90), 0, 0)
}
local TweeningPlaying = Tween:Create(Hinge, Info1, OpeningTable2)
local TweeningPlaying2 = Tween:Create(MetalBar2, Info, OpeningTable1)
script.Parent.MouseClick:Connect(function()
Sound:Play()
TweeningPlaying:Play()
game.Workspace.GreenPart1.BrickColor = BrickColor.new("Lime green")
print("Opening the first one")
TweeningPlaying2:Play()
print("Opening the second one")
wait(0.5)
Sound:Destroy()
end)
It looks like the problem is in openingtable1, when you multiply cframes, it is basically adding them. This means that you are adding -51.437 to the metalbar2 cframe y axis. You are actually adding the x and z axis on top of the actual position, which us why it moves so far. I suggest reading up on the use of cframes.
Yo well you were correct lol I shouldn’t have multiplied it, Anyways it now does go up to the point I want it to but it apparently rotates? idk why it does that, Any idea?
Sometimes when you rotate or turn an object while creating it. What appears to be up and down is actually sideways. As all the axes have been changed. IDK if that is your problem or not. You should try to break this down to just your problem spot. Try to just tween the door only untill you get that working. Then come back and add the rest.