So there’s a Seat where the Gui pops up and there’s a button “Door Open” and “Door Close”
i want to achieve that if i click “Door Open” Button, The Value “Door” is on then The first Picture with the door is obviously open. I did the script but it doesn’t somehow work and there’s no tutorial about it.
(it’s like a Tatra Door or old Trolleybus Door)
i use HingeConstraint for the Door.
not only the button will open the doors. The Values will open the doors.
Script will be sended in the Thread.
Please help me this is urgent.
Note: The Hinge Constraint is Servo
The Solution i tried to found is nowhere. I tried ChatGPT, i Tried Roblox Studio Forum so to find and i tried to find a tutorial on YouTube.
It’s basiclly a Door from Tram 2000
wait(0.1)
-- Thani --
local ButtonL = script.Parent.ButtonL
local ButtonR = script.Parent.ButtonR
local ClickDetectorL = ButtonL.Button.ClickDetector
local ClickDetectorR = ButtonR.Button.ClickDetector
local LHinge = script.Parent.Hinge.L
local RHinge = script.Parent.Hinge.R
local BottomHinge = script.Parent.Floor.Hinge.HingeConstraint
local OpenSound = script.Parent.Part.Open
local CloseSound = script.Parent.Part.Close
local DoorValue = script.Parent.Parent.Parent.Values.Door
local ButtonValue = script.Parent.Parent.Parent.Values.Button
ClickDetectorL.MouseClick:Connect(function()
if ButtonValue.Value == true then
if script.Parent.Open.Value == false then
LHinge.AngularSpeed = 8
RHinge.AngularSpeed = 8
LHinge.TargetAngle = 150
RHinge.TargetAngle = -150
LHinge.ServoMaxTorque = 9
RHinge.ServoMaxTorque = 9
BottomHinge.TargetAngle = -90
script.Parent.Open.Value = true
OpenSound:Play()
wait(7)
LHinge.ServoMaxTorque = 7
RHinge.ServoMaxTorque = 7
LHinge.AngularVelocity = 8
RHinge.AngularVelocity = 8
CloseSound:Play()
LHinge.TargetAngle = 0
RHinge.TargetAngle = 0
script.Parent.Open.Value = false
BottomHinge.TargetAngle = 0
end
end
end)
ClickDetectorR.MouseClick:Connect(function()
if ButtonValue.Value == true then
if script.Parent.Open.Value == false then
LHinge.AngularSpeed = 8
RHinge.AngularSpeed = 8
LHinge.TargetAngle = 150
RHinge.TargetAngle = -150
LHinge.ServoMaxTorque = 9
RHinge.ServoMaxTorque = 9
BottomHinge.TargetAngle = -90
script.Parent.Open.Value = true
OpenSound:Play()
wait(7)
LHinge.ServoMaxTorque = 7
RHinge.ServoMaxTorque = 7
LHinge.AngularVelocity = 8
RHinge.AngularVelocity = 8
CloseSound:Play()
LHinge.TargetAngle = 0
RHinge.TargetAngle = 0
script.Parent.Open.Value = false
BottomHinge.TargetAngle = 0
end
end
end)
while true do
if ButtonValue.Value == true then
ButtonL.Light.BrickColor = BrickColor.new("Neon green")
ButtonR.Light.BrickColor = BrickColor.new("Neon green")
elseif ButtonValue.Value == false then
ButtonL.Light.BrickColor = BrickColor.new("Really black")
ButtonR.Light.BrickColor = BrickColor.new("Really black")
end
wait(0.1)
end
local function onValueChanged()
if DoorValue.Value == true then
LHinge.AngularSpeed = 8
RHinge.AngularSpeed = 8
LHinge.TargetAngle = 150
RHinge.TargetAngle = -150
LHinge.ServoMaxTorque = 9
RHinge.ServoMaxTorque = 9
BottomHinge.TargetAngle = -90
script.Parent.Open.Value = true
OpenSound:Play()
else
LHinge.ServoMaxTorque = 7
RHinge.ServoMaxTorque = 7
LHinge.AngularVelocity = 8
RHinge.AngularVelocity = 8
CloseSound:Play()
LHinge.TargetAngle = 0
RHinge.TargetAngle = 0
script.Parent.Open.Value = false
BottomHinge.TargetAngle = 0
end
end
-- Connect the function to the ValueChanged event of the BoolValue
DoorValue.ValueChanged:Connect(onValueChanged)