Hey everyone, I’ve been stuck with this issue for a while now and it’s honestly driving me crazy. I’m working on a game of self-driving AI cars (about eight of them) that drive around a racing circuit using waypoints. The goal is to have them complete continuous laps smoothly, just like normal cars in a racing game.
Everything works perfectly during the first lap, but once the cars start their second lap, specifically near the main straightaway (where the player spawns), everything begins to fall apart. When they get close to the player, they begin to behave erratically (weaving side to side on the straight, braking randomly mid-straight, or missing braking zones in corners). Sometimes they overshoot corners slightly but still manage to turn in. It consistently happens after the second lap is completed. It almost feels like their steering or navigation logic breaks down when the player’s character is nearby.
What I’ve tried so far:
Set Network Ownership of all cars to the server: no change.
Tried enabling StreamingEnabled: this actually fixes the issue, but it introduces another problem, the limited render distance ruins the look of the track since everything distant disappears.
Checked the waypoint logic, pathing loops, and update intervals: nothing obviously wrong.
Tried to look up any similar issues on the DevForum, but couldn’t find anything that matches this specific problem.
This seems to be a network issue as things close or in the network radius to the player are automatically given ownership to the player unless its multiplayer. Double check your code and make sure your either setting network ownership on the RootPart of the car or setting the network ownership of every part in the car. Try this and let me know if it works, Also try using screenshots and videos its really helpful @EnzoProductions2020
When a server script doesnt have ownership the car physics become unpredictable because the player controls the cars physics which in this case could explain why the cars swerve from side to side
I tried your suggestions and replaced the script inside the car, but honestly, it doesn’t seem to have helped much. The cars are still stuttering and behaving erratically like before.
local body = vehicleSeat.Parent
local car = body.Parent
local function setVehicleNetworkOwner()
for _, part in ipairs(car:GetDescendants()) do
if part:IsA("BasePart") then
part:SetNetworkOwner(nil)
end
end
end
vehicleSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
setVehicleNetworkOwner()
end)
setVehicleNetworkOwner()
Here is a video displaying the behavior mentioned before:
This just doesn’t make sense, man. I moved the spawnpoint far away from the racing line, and suddenly the cars started working perfectly again. I don’t understand how the player’s presence near the circuit makes the server lag or stutter visually, completely messing up the AI cars, by the way.
it was made in this way (without having option disable this auto system)
find this button or if in Next gen gui studio then there should be some small button
then find this in physics labels and enabled Network owners (and show us video with this enabled while being nearby with a driving-car by AI)
Wow! That might definitely be the issue. The white outlines of the car parts turned green so it should indicate that the player has taken NetworkOwnership of the cars. So, how do I stop that from happening?
told you it was a network problem lol. but does is the vehicle seat in your car weld to everything if that is then you can just set the network ownership of the vehicle seat
you could try looping and making sure network ownership is on the server but im pretty sure that would cause lag. I will be leaving this conversation as I dont have hours on end to wait for replies so hope you fix your AI system.