Raycast Vehicle

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

  1. What do you want to achieve? A smooth vehicle with suspension by raycasting.

  2. What is the issue? Quite bouncy without me or any player doing anything, bounces a large amount when I switch application or select, then deselect it, and sometimes just falls to the ground on start, and stays there.

  3. What solutions have you tried so far? Tried changing values, positions, and surfed all over the web.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Full Server-Sided Script: [REDACTED]

1 Like

Any errors in the Output window?

Try printing variables to let you know where the issue is.
For example after you fire the ray print the RaycastResult.

Wait up…

			task.spawn(function()
				if VisualiseRays then
					local RayPart = Instance.new("Part")
					RayPart.Parent = CarModel:WaitForChild("Rays")
					RayPart.Name = "RayPart"
					RayPart.Color = Color3.fromRGB(255, 0, 0)
					RayPart.Anchored = true
					RayPart.CanCollide = false
					RayPart.Material = Enum.Material.Neon
					RayPart.Massless = true

How are you Welding this Part when you create it?

The script mostly works, so no errors, it’s just the stuff that I filled out for question 2 that’s the issue. The RayParts aren’t welded, but that isn’t the issue.

Ah, I see, the RayPart gets CFramed in the last section.
I can’t see them in the video though.

Could the issue be that the ray you are casting downward is hitting the RayPart and you get a reading from that?

Another thing, you set the NetworkOwnership when there is a change to the VehicleSeat, but what about when a player gets near? Doesn’t the NetworkOwnership of anything change when a player gets close to an item? If so then you are setting it to nil, then the player getting close gets ownership.

Like I said, try print statements in your loops for troubleshooting. Something like print CarPrimaryPart’s ownership to see if it’s changing.

I disabled being able to see the ray parts, it’s under an if statement which has a false condition so it won’t run.

Blacklisted from raycast already.

I’m not quite sure what you mean, could you elaborate?

It doesn’t change unless I change it, I’ve tried it before.

the car falls because a player is taking control over the physics calculations instead of the server, set the car’s primary part’s network ownership to nil

also i know where this script is from, it’s a YouTube tutorial by Krokosha666, and if you watch it all the way, all your issues will be addressed

Already fixed, I used vector forces instead of ApplyImpulseAtPosition. I also talked to Krokosha666, and he said that his tutorial left out some bits on purpose to ensure players didn’t have the exact same code and functionality as him, so techinically, all my issues wouldn’t have been addressed with that video.