I scripted a CFrame moving bus waypoint based system that works nicely. I also added door opening and closing through Motor6D.Transform (I used motor because the doors need to move with the bus and on their own). While this works perfectly on the server (run mode), on the client (play mode) only the movement works and not the doors. I tried doing the door movement on a local script and use remote events, but still no luck. Any ideas?
#bus door problem
1 messages · Page 1 of 1 (latest)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local DoorEvent = ReplicatedStorage:WaitForChild("BusDoorControl1")
local bus = workspace:WaitForChild("Bus1")
local openOffsets = {
BLDoorRoot = Vector3.new(2.557, 0, 0),
BRDoorRoot = Vector3.new(-2.557, 0, 0),
MLDoorRoot = Vector3.new(2.557, 0, 0),
MRDoorRoot = Vector3.new(-2.557, 0, 0),
FLDoorRoot = Vector3.new(-2.557, 0, 0),
FRDoorRoot = Vector3.new(2.557, 0, 0)
}
local doorMotors = {}
-- Collect motors
for _, child in pairs(bus:GetDescendants()) do
if child:IsA("Motor6D") and openOffsets[child.Parent.Name] then
doorMotors[child.Parent.Name] = {
Motor = child,
Offset = openOffsets[child.Parent.Name]
}
end
end
local function animateDoors(open)
for _, data in pairs(doorMotors) do
local offset = open and data.Offset or Vector3.zero
local tween = TweenService:Create(data.Motor, TweenInfo.new(1), { Transform = CFrame.new(offset) })
tween:Play()
end
end
DoorEvent.OnClientEvent:Connect(function(action)
if action == "Open" then
animateDoors(true)
elseif action == "Close" then
animateDoors(false)
end
end)```
-- Main movement loop
while true do
for _, wp in ipairs(orderedWaypoints) do
tweenTo(wp.CFrame)
if CollectionService:HasTag(wp, "Stop") then
DoorEvent:FireAllClients("Open")
wait(5)
DoorEvent:FireAllClients("Close")
end
end
end