Hello,
So here’s the problem when I click the text button to open the doors they work the first time right but then after the bus is undriveable oh and also the bus worked before i clicked it, i’d appreciate it so much if someone helped me. Here’s a video showing it: https://gyazo.com/cb8a59a21b6e777de460aafc6aae0571
Server Script
local TweenService = game:GetService("TweenService")
local remoteEvent = game.ReplicatedStorage:WaitForChild("DoorRequestEvent")
-- BUS DOORS
local LeftBusDoor = script.Parent:WaitForChild("BusDoors"):WaitForChild("LeftBusDoor"):WaitForChild("LeftDoor")
local RightBusDoor = script.Parent:WaitForChild("BusDoors"):WaitForChild("RightBusDoor"):WaitForChild("RightDoor")
local LeftClosedInv = script.Parent:WaitForChild("BusDoors"):WaitForChild("LeftBusDoor"):WaitForChild("LeftClosedDoorInv")
local LeftOpenInv = script.Parent:WaitForChild("BusDoors"):WaitForChild("LeftBusDoor"):WaitForChild("LeftOpenDoorInv")
local RightClosedInv = script.Parent:WaitForChild("BusDoors"):WaitForChild("RightBusDoor"):WaitForChild("RightClosedDoorInv")
local RightOpenInv = script.Parent:WaitForChild("BusDoors"):WaitForChild("RightBusDoor"):WaitForChild("RightOpenDoorInv")
-- Function to handle the door movement
local function handleDoorRequest(player, doorOpen)
print(doorOpen)
print("Found the Bus doors")
for _, doorObj in pairs(script.Parent.BusDoors:GetDescendants()) do
if doorObj:IsA("BasePart") or doorObj:IsA("UnionOperation") then
doorObj.Anchored = true
--doorObj.CanCollide = false
end
end
local openleftPosition = LeftOpenInv.Position
local closedLeftPosition = LeftClosedInv.Position
local openRightPosition = RightOpenInv.Position
local closedRightPosition = RightClosedInv.Position
local tweenInfo = TweenInfo.new(1)
local tweenLeftOpen = TweenService:Create(LeftBusDoor, tweenInfo, {Position = openleftPosition})
local tweenRightOpen = TweenService:Create(RightBusDoor, tweenInfo, {Position = openRightPosition})
local tweenLeftClose = TweenService:Create(LeftBusDoor, tweenInfo, {Position = closedLeftPosition})
local tweenRightClose = TweenService:Create(RightBusDoor, tweenInfo, {Position = closedRightPosition})
-- Move the doors based on the doorOpen parameter
if doorOpen then
tweenLeftOpen:Play()
tweenRightOpen:Play()
print("Door Opened")
tweenRightOpen.Completed:Wait()
LeftBusDoor.Position = LeftOpenInv.Position
RightBusDoor.Position = RightOpenInv.Position
else
tweenLeftClose:Play()
tweenRightClose:Play()
print("Door Closed")
tweenRightClose.Completed:Wait()
LeftBusDoor.Position = LeftClosedInv.Position
RightBusDoor.Position = RightClosedInv.Position
end
end
-- Event listener for handling door requests
remoteEvent.OnServerEvent:Connect(handleDoorRequest)
Client script for the text button
local remoteEvent = game.ReplicatedStorage.DoorRequestEvent
local button = script.Parent.OpenBusDoors
local doorsOpen = false
local cooldownActive = false
local cooldownDuration = 4 -- Cooldown duration in seconds
local function onButtonClicked()
if not cooldownActive then
doorsOpen = not doorsOpen
remoteEvent:FireServer(doorsOpen)
cooldownActive = true
if doorsOpen then
button.Text = "Close Bus Doors"
else
button.Text = "Open Bus Doors"
end
wait(cooldownDuration)
cooldownActive = false
end
end
button.MouseButton1Click:Connect(onButtonClicked)