Script isn't working

Hey y’all! I’m in the process of trying to make a simple script. I’m a builder, so I have little to none scripting experience and this is my script:

script.Parent.Touched:connect(function(Touched)
	if Touched.ClassName == "DriveSeat" then
		Touched.Parent.DriveSeat.MaxSpeed = 60
	end

It is giving me an error saying “Expected “(” to close Function on line 1; did you forget to close “then” on line 2?”

Anyone know how to fix this?

script.Parent.Touched:Connect(function(Touched)
	if Touched.ClassName == "VehicleSeat" then
		Touched.Parent.DriveSeat.MaxSpeed = 60
	end
end)

you have to close off the function with end, the ) is there because you never closed the first ( on line 1

also use Connect instead of connect

1 Like

DriveSeat isn’t even a valid classname.

local seat = script.Parent

seat.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("HumanoidRootPart") then --player touched seat
		if seat:IsA("VehicleSeat") then
			seat.MaxSpeed = 60
		end
	end
end)

image

This simple script just detects if a player is touching the seat and then sets the max speed to 60.

1 Like

forgot to change the class name my bad
you still shouldn’t use connect though

Yeah, he should use the Occupant property which belongs to both “Seat” instances & “VehicleSeat” instances and then detect a signal change, I didn’t want to stray too far away from the original script however.