Seat:Sit() NOT WORKING!

script.Parent.Touched:Connect(function(Player)
	if game.Players:GetPlayerFromCharacter(Player.Parent) then
		local Seats = game.Workspace.MyTruckLane1.Seats
		for i, v in pairs(Seats:GetChildren()) do
			v:Sit(Player.Parent.Humanoid)


		end
	end
end)

Im not to sure why this isnt working and this is a shortened piece of code from a main script i cant understand why its not sitting the player. Does anyone have any answers?

1 Like

try this

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("HumanoidRootPart") then -- checking if its a player
		local Seats = game.Workspace.MyTruckLane1.Seats
		for i, v in pairs(Seats:GetChildren()) do
			if v.Occupant == nil then -- checking if seat is not occupied
				v:Sit(hit.Parent.Humanoid)
				break -- break when script finds untaken seat
			end
		end
	end
end)

if this works please mark this as solution :slight_smile:

1 Like

For some reason it still isnt working im not sure why there is 8 seats in the folder “Seats” and the whole code it running its just not putting the player in the seat :face_with_raised_eyebrow:

1 Like

Seat:Sit() cannot be called from the client.

I know this is an old post but in case you weren’t aware of that convention.

https://developer.roblox.com/en-us/api-reference/function/Seat/Sit

5 Likes

This is strange, as in the documentation this is not mentioned. Also, when I test in Studio, Sit works in LocalScript.
But testing in Roblox Player, doesn’t always work.
Then I changed Sit to Server and it worked every time.
Another one of the darkest things about Roblox…

2 Likes