(Help) VehicleSeat is not a valid member of Workspace "Workspace"

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I made a script where a player sits on a seat part when they pressed a ProximityPromp

  2. What is the issue? Include screenshots / videos if possible!
    I keep getting the error and my script is not working
    Capture2
    Capture

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I dont know what to do.

function sitOn(humanoid : Humanoid, seat)
	seat:Sit(humanoid)
end
workspace.VehicleSeat.ProximityPrompt.Triggered:Connect(function(player)
	sitOn(player.Character.Humanoid,workspace.VehicleSeat)
	print(player.Character.Humanoid)
end)
workspace.Seat.ProximityPrompt.Triggered:Connect(function(player)
	sitOn(player.Character.Humanoid,workspace.Seat)
	print(player.Character.Humanoid)
end)
1 Like

When you play the game does the seat still appear as normal in the workspace?

yes. the seat is there before i hit play

I mean when you press play and run the game, go into workspace and see if it’s still there.

Another issue, is that it might not be anchored and when parts fall off and go into the “void” they get destroyed.

1 Like

Hi , you need to use :WaitForChild() because the script loads before the workspace so it cannot find the seat part and cause a error, Hope this helps! :slightly_smiling_face:

function sitOn(humanoid : Humanoid, seat)
	seat:Sit(humanoid)
end
workspace:WaitForChild("VehicleSeat").ProximityPrompt.Triggered:Connect(function(player)
	sitOn(player.Character.Humanoid,workspace.VehicleSeat)
	print(player.Character.Humanoid)
end)
workspace:WaitForChild("Seat").ProximityPrompt.Triggered:Connect(function(player)
	sitOn(player.Character.Humanoid,workspace.Seat)
	print(player.Character.Humanoid)
end)

Yes its still there also the script i post is the only one in game

So i have to use wait for child for any part in workspace i call? if i want to loop from all seats do i have to waitforchild of any of them? i heard that wait for child is expensive

If the script runs when game is first started, yes. If it makes sure that the part is loaded or the game is loaded, you dont need to use it because its already loaded and doesnt need to wait again :slightly_smiling_face:

You can also do

repeat wait() until game:IsLoaded()

this will wait for everything to be loaded

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.