You’ve got to have another script hidden in there somewhere that is controlling the doors and CFraming them. It might explain why you were having issues in the first place.
The fact that the tweenservice line is in the script makes no difference (but I should have put – in front of it) since the rest of the script doesn’t use it. It’s like putting an extra variable at the beginning of a script that you never use.
Nope there’s no hidden script I used Find all/ Replace all. Edit I found the problem the body was unanchored but now the script wont work when I click.
--local TweenService = game:GetService("TweenService")
h = script.Parent.BusDoorsRight.Frameofbusdoors.Hinge.HingeConstraint
val = script.Parent.Doors
local remoteEvent = game.ReplicatedStorage:WaitForChild("DoorRequestEvent")
-- BUS DOORS
--[[local LeftBusDoor = script.Parent:WaitForChild("BusDoorsLeft"):WaitForChild("LeftOpenDoorInv")
local RightBusDoor = script.Parent:WaitForChild("BusDoorsRight"):WaitForChild("RightOpenDoorInv")
local LeftClosedInv = script.Parent:WaitForChild("BusDoorsLeft"):WaitForChild("LeftClosedDoorInv")
local LeftOpenInv = script.Parent:WaitForChild("BusDoorsLeft"):WaitForChild("LeftDoor")
local RightClosedInv = script.Parent:WaitForChild("BusDoorsRight"):WaitForChild("RightClosedDoorInv")
local RightOpenInv = script.Parent:WaitForChild("BusDoorsRight"):WaitForChild("RightBusDoor") ]]
-- 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.Name == "LeftDoor" or doorObj.Name == "RightDoor" then
doorObj.Anchored = true
--doorObj.CanCollide = false
end
end
local openLeftCFrame = LeftOpenInv.CFrame
local closedLeftCFrame = LeftClosedInv.CFrame
local openRightCFrame = RightOpenInv.CFrame
local closedRightCFrame = RightClosedInv.CFrame
local tweenInfo = TweenInfo.new(1)
local tweenLeftOpen = TweenService:Create(LeftBusDoor, tweenInfo, {CFrame = openLeftCFrame})
local tweenRightOpen = TweenService:Create(RightBusDoor, tweenInfo, {CFrame = openRightCFrame})
local tweenLeftClose = TweenService:Create(LeftBusDoor, tweenInfo, {CFrame = closedLeftCFrame})
local tweenRightClose = TweenService:Create(RightBusDoor, tweenInfo, {CFrame = closedRightCFrame}) ]]
-- Move the doors based on the doorOpen parameter
if (val.Value == false) then
val.Value = true
h.TargetAngle = -90
--tweenLeftOpen:Play()
--tweenRightOpen:Play()
print("Door Opened")
--tweenRightOpen.Completed:Wait()
else
val.Value = false
h.TargetAngle = 0
--tweenLeftClose:Play()
--tweenRightClose:Play()
print("Door Closed")
--tweenRightClose.Completed:Wait()
end
end
--print(LeftBusDoor.CFrame,RightBusDoor.CFrame)
-- Event listener for handling door requests
remoteEvent.OnServerEvent:Connect(handleDoorRequest)
Here’s what I’m talking about: Bus Doors.rbxm (13.8 KB)
It’s just a tutorial vehicle chassis, and each of the doors are run by a clickdetector, but you can see how I’ve done it. You can script the doors to be activated with your remoteEvent.