script.Parent.BusOn.OnServerEvent:Connect(function(plr)
local driverSeat = script.Parent:FindFirstChild("DriverSeat")
if not driverSeat or not driverSeat:IsA("VehicleSeat") then
return
end
if not driverSeat.Occupied and driverSeat.SeatOccupant then
driverSeat.Occupied = true
driverSeat.SecondOccupied = true
print("Finding radio audio")
local radioSound = driverSeat:FindFirstChild("RADIO")
if radioSound and radioSound:IsA("Sound") then
radioSound:Play()
print("Played radio")
end
print("Finding WTS")
local wtsSound = driverSeat:FindFirstChild("WTS")
if wtsSound and wtsSound:IsA("Sound") then
wtsSound:Play()
end
print("Waiting for delay")
wait(5)
driverSeat.SecondOccupied = false
print("Bus on.")
end
end)
Client script (StarterGUI):
local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local hum = plr.Character:WaitForChild("Humanoid")
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.M then
if hum.Sit == true then
game.Workspace["Thomas C2 School Bus"].DS.BusOn:FireServer()
print("Actived RE")
end
end
end)
Assuming “driverSeat” is a basic VehicleSeat class, the properties “Occupied” and “SeatOccupant” do not exist, I assume you’re looking for VehicleSeat.Occupant (which would either be a Humanoid or nil)
What you’re looking for I assume to check if the requesting client is sitting in the driver seat. Utilize the Occupant property. In this solution, you’d simply compare the occupant (which is a Humanoid class) to the humanoid of the client. If no one is sitting in the seat, occupant would be nil and the condition would not pass.
if driverSeat.Occupant == plr.Character.Humanoid then
-- code...
script.Parent.BusOn.OnServerEvent:Connect(function(plr)
local driverSeat = script.Parent:FindFirstChild("DriverSeat")
if not driverSeat or not driverSeat:IsA("VehicleSeat") then
return
end
if driverSeat.Occupant == plr.Character.Humanoid then
driverSeat.Occupied = true
driverSeat.SecondOccupied = true
print("Finding radio audio")
local radioSound = driverSeat:FindFirstChild("RADIO")
if radioSound and radioSound:IsA("Sound") then
radioSound:Play()
print("Played radio")
end
print("Finding WTS")
local wtsSound = driverSeat:FindFirstChild("WTS")
if wtsSound and wtsSound:IsA("Sound") then
wtsSound:Play()
end
print("Waiting for delay")
wait(5)
driverSeat.SecondOccupied = false
print("Bus on.")
end
end)
client:
local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local hum = plr.Character:WaitForChild("Humanoid")
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.M then
if hum.Sit == true then
game.Workspace["Thomas C2 School Bus"].DS.BusOn:FireServer()
print("Actived RE")
end
end
end)