#Can anyone tell me why the script is unable to find VehicleSeat
1 messages · Page 1 of 1 (latest)
When playing the game, if you check in the explorer, is VehicleSeat there?
That's a lot of code to look through, so it'd help if you just show the part where it attempts to find VehicleSeat
Fair enough will do:
local function setupCarListener(carModel: Model)
-- ... (Code inside the function below) ...
end
-- Gets the car model as input (e.g., Workspace.Car)
local bodyPart = carModel:FindFirstChild("Body")
-- Checks if 'Body' was actually found. If not, it stops processing this car.
if not bodyPart then return end
-- Now searches inside the 'bodyPart' found above
local driverSeat = bodyPart:FindFirstChildWhichIsA("VehicleSeat")
-- Checks if a 'VehicleSeat' was actually found inside 'bodyPart'. If not, it stops.
if not driverSeat then return end
and if you look in the explorer while the game is running? Is it still there?
Yea it is
** You are now Level 3! **
What if you print out the children of the body & print out the driverSeat variable? Just trying to rule some stuff out and debug a bit
Debug output
Did you :WaitForChild since you're looking for the seat on the client? I know that isn't directly the same as FindFirstChildWhichIsA, but the seat may not replicate in time, so I'd want to analyze that
will try to swap it out
I get this output
18:32:29.276 Stack End - Studio
18:32:32.991 Players.fru_buski.PlayerScripts.VehicleEntryController:135: attempt to call a nil value - Client - VehicleEntryController:135
18:32:32.991 Stack Begin - Studio
18:32:32.991 Script 'Players.fru_buski.PlayerScripts.VehicleEntryController', Line 135 - Studio - VehicleEntryController:135
18:32:32.991 Stack End - Studio
The lines in question here are
-- Setup Enter Prompt Listener
if not carPromptConnections[prompt] then
carPromptConnections[prompt] = prompt.Triggered:Connect(function()
if not isSeated and not isTransitioning then
handleEnterCar(prompt)
end
end)
prompt.Destroying:Connect(function()
if carPromptConnections[prompt] then
carPromptConnections[prompt]:Disconnect()
carPromptConnections[prompt] = nil
end
end)
end
Hmm, this is a different issue than we were just debugging
handleEnterCall could be nil
Are you seeing anything about an infinite yield? How did you add WaitForChild?
The places where WaitForChild are here was just changed from findfirstchildwhichisa to waitforchild
local function setupCarListener(carModel: Model)
local bodyPart = carModel:FindFirstChild("Body")
if not bodyPart then return end
local driverSeatInstance = bodyPart:WaitForChild("VehicleSeat", WAIT_TIMEOUT)
if not driverSeatInstance or not driverSeatInstance:IsA("VehicleSeat") then
warn("VehicleEntryController: Failed to find a valid VehicleSeat named 'VehicleSeat' in", bodyPart:GetFullName())
return
end
local driverSeat = driverSeatInstance :: VehicleSeat
local promptInstance = driverSeat:WaitForChild("ProximityPrompt", WAIT_TIMEOUT)
if not promptInstance or not promptInstance:IsA("ProximityPrompt") then
warn("VehicleEntryController: Failed to find a valid ProximityPrompt named 'ProximityPrompt' in", driverSeat:GetFullName())
return
end
and it still says that it doesn't exist?
Can you print out all the children of "Body" just before you wait for it?
Check in the explorer both on the server & client to confirm it's still there too
Maybe a task.wait(10) just before your clientside workspace scan
It's either slow to replicate or just not there
are you trying to find a model inside the seat?
oh sorry nevermind
What's the event name constant?
This?
No like the constant you use, what's the value of that? the one you use to search
Oh 2 sec
ENTER_REMOTE_EVENT_NAME: The value is "EnterVehicleEvent".
EXIT_REMOTE_EVENT_NAME: The value is "ExitVehicleEvent".
Okay that looks fine.
I mean generally when the client can't find something from the server it means it hasn't replicated yet. Did you add that task.wait before the workspace scan on the client?
Ah okay, so we found the VehicleSeat fine. So printing those children aren't important anymore
So I guess we need to make sure we're looking for the event in the right spot.
It's a bit tough to look through all of that output on my phone, but maybe just a single print to say where it's looking from, and just one line here to tell me what the output was
The script fails right after the line VehicleEntryController: > handleEnterCar - carModel found: Body. It then tries to run carModel:FindFirstChild("EnterVehicleEvent") and that fails.
So, the script thinks the variable carModel (which it got from seat:FindFirstAncestorOfClass("Model")) refers to the object named "Body". It's looking for the "EnterVehicleEvent" directly inside that object named "Body" according to the log, but it can't find it there.
And i just realized im stupid the EnterVehicleEvent isnt directly inside of Body its inside of Car
Oh lol yes I just saw that now too
Well now i just get the fadein and fadeout i dont actually get in the car... I mustve just wrote everything wrong bro 😭
Well you're partly there! things are happening which is great
Yeah true