I’ve made a functioning door, but the way the door closes is a problem for me, it does a weird flip when I try to close the door and it’s too unrealistic for my game, also I for some reason have to double click it, for some reason it only needs to be double clicked once and then it starts to function as ussual, so if anyone could help me a tiny bit, it would be apreciated.
local TweenService = game:GetService("TweenService")
local ClickDetector = script.Parent.ClickDetector
local part = script.Parent
local position = script.Bool
local info = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false)
local newRotation = part.Rotation + Vector3.new(0, 90, 0)
local newPosition = part.Position + Vector3.new(3, 0, 3)
local tween = TweenService:Create(part, info, {Position = newPosition, Rotation = newRotation})
local CloseRotation = part.Rotation + Vector3.new(0, 0, 0)
local ClosePosition = part.Position + Vector3.new(0, 0, 0)
local tween2 = TweenService:Create(part, info, {Position = ClosePosition, Rotation = CloseRotation})
local Cooldown = script.Cooldown.Value
if Cooldown == false then
ClickDetector.MouseClick:Connect(function()
if position == false then
tween:Play()
position = true
wait(2)
else
tween2:Play()
position = false
wait(2)
end
end)
end
switch the click detector function’s place with the if statement for the cooldown. change newRotation to Vector3.new(0,math.rad(90),0). also for the closerotation you are adding it by 0 so it wont move at all. in the tween and tween2, change position = to CFrame = CFrame.new(newPosition) * CFrame.Angles(newRotation). to fix the double click problem try changing position = script.Bool to position = false
to tween CFrames instead of doing cframe.new(), CFrame.Angles() you have to multiply them like CFrame.new() * CFrame.Angles(). also yeah the code seems like it could work
change CFrame.Angles(0,-90,0) to CFrame.Angles(0,math.rad(-90),0) also if something goes wrong send a picture instead of a video cuz for some reason they arent loading (probably cuz of my device)