I want to make a pathfinding script to a car, but the car should only be able to drive on the roads. Therefore I want to create a wall that the players can walk through, but not an NPC car.
I made a simple pathfinding script, but I don't know how to make it so it can't go off the road.
while true do path = game:GetService("PathfindingService"):ComputeRawPathAsync(workspace.Start.Position, workspace.Finish.Position, 400); points = path:GetPointCoordinates() game.Workspace.Points:ClearAllChildren() for p = 1, #points do part = Instance.new("Part"); part.FormFactor = Enum.FormFactor.Symmetric part.CanCollide = false part.Size = Vector3.new(1,1,1) part.Position = points[p] part.Anchored = true part.BrickColor = BrickColor.Gray() part.Parent = game.Workspace.Points end wait(0.5) end
Please help. Thanks!
Long story short, you'd need filtering enabled turned on for this.
Long story long:
Turn on FilteringEnabled (Workspace > FilteringEnabled > Mark the checkbox)
Put (build) parts around the road.
Make a localscript that removes all of those parts (from the client).
Result: The server will know about the parts. The server will not let any parts through, but the player will be able to walk through it, because for the player it'll look like they're gone (And they actualy are for that player.)
(Also FormFactor is deprecated and won't have any effects anymore.)
What he said ^^^^^^^