Trying to script a car. Applying RotVelocity to the wheels when the character presses W. But for some reason, when the character sits in the seat on the car, RotVelocity just stops working altogether. The car doesn't move at all. Not sure why this is happening.

Also, can someone point me towards where to learn to script a car? For some odd reason, I can't find any "script a car in roblox" tutorials. There are ones that will teach you how to build a car using welds and constraints and stuff, but I want one that will teach you how to properly script a car. Because honestly, I don't know if the way I'm doing it is the most efficient way. When I apply RotVelocity to the wheels, the wheels slide and stuff, and most of the time, the car will go forward a little bit, then just stop.

If anyone wants it, here's the script:

-- Created by TheEthanMaverick

local player = nil

-- Normally I'd use the Touched event, but it was having an issue where sometimes the player would
-- occupy the seat without "touching" the seat, so the Touched event would never fire.
while true do
	
	if script.Parent:FindFirstChild("signal") ~= nil then
		
		player = workspace:FindFirstChild(script.Parent.signal.Value)
		
		while true do
			
			if script.Parent:FindFirstChild("signal") == nil then
				break
			end
			
			if player.Input.Booleans.W.Value == true then
				script.Parent.Parent.BL.RotVelocity = Vector3.new(0, 0, -100)
				script.Parent.Parent.BR.RotVelocity = Vector3.new(0, 0, -100)
			elseif player.Input.Booleans.A.Value == true then
				print("A")
			elseif player.Input.Booleans.S.Value == true then
				script.Parent.Parent.BL.RotVelocity = Vector3.new(0, 0, 100)
				script.Parent.Parent.BR.RotVelocity = Vector3.new(0, 0, 100)
			elseif player.Input.Booleans.D.Value == true then
				print("D")
			else
				print("none")
			end
			
			wait(0.1)
		end
		
	end
	
	wait(0.1)
end

2 comments

0

why dont you use seat:GetPropertyChangedSignal("Occupant")?

0

@Leamir I've never heard of that before. Could be quite useful. Will look into it, thank you.