--variables local body = script.Parent local rightRay = Ray.new(body.Position,Vector3.new(0,0-10)) local leftRay = Ray.new(body.Position,Vector3.new(-10,0,0)) local backRay = Ray.new(body.Position,Vector3.new(10,0,0)) local vs = script.Parent.Parent.VehicleSeat --start the car vs.Throttle = 1 --do the movements every 1 second while wait(1) do --this is to do trafic speed mantaince and crosswals local frontRay = Ray.new(body.Position,Vector3.new(0,0,-30)) local hit,Position = game.Workspace:FindPartOnRayWithIgnoreList(frontRay,{body}) local crosswalk = game.Workspace.CrswlkObj if hit == crosswalk then print("Reached Cross walk") vs.Throttle = hit.Velocity.Z wait(1) vs.Throttle = 1 end --this is the line follower end
Please help. Sorry if the answer is very simple. Thanks
--variables local body = script.Parent local rightRay = Ray.new(body.Position,Vector3.new(0,0-10)) local leftRay = Ray.new(body.Position,Vector3.new(-10,0,0)) local backRay = Ray.new(body.Position,Vector3.new(10,0,0)) local vs = script.Parent.Parent.VehicleSeat local RunService= game:GetService("RunService") --start the car vs.Throttle = 1 --do the movements every 1 second RunService.RenderStepped:Connect(function() --this is to do trafic speed mantaince and crosswals local frontRay = Ray.new(body.Position,Vector3.new(0,0,-30)) local hit,Position = game.Workspace:FindPartOnRayWithIgnoreList(frontRay,{body}) local crosswalk = game.Workspace.CrswlkObj if hit == crosswalk then print("Reached Cross walk") vs.Throttle = hit.Velocity.Z wait(1) vs.Throttle = 1 end --this is the line follower end) --ok