Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make so a player can walk through a wall, but nothing else can?

Asked by 7 years ago

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!

0
You could place the wall in everyone's Camera and manipulate it accordingly to each client. Goulstem 8144 — 7y

2 answers

Log in to vote
1
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

Long story short, you'd need filtering enabled turned on for this.

Long story long:

  1. Turn on FilteringEnabled (Workspace > FilteringEnabled > Mark the checkbox)

  2. Put (build) parts around the road.

  3. 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.)

Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

What he said ^^^^^^^

1
You cant use localparts, as the SERVER has to see the part, but the PLAYER doesnt. Also, make this a comment. RubenKan 3615 — 7y
1
Ruben, the hell are you talking about? KillPowerAlex135 5 — 7y
0
He wants an NPC car to not drive through it, Aka the SERVER needs the part, and the CLIENT does not. A LocalPart is something that's only visible to the Client, and not the server. This guy needs the opposite, so you can't use localparts. RubenKan 3615 — 7y
0
Okay. That makes more sense. That part was difficult to understand in the question. KillPowerAlex135 5 — 7y

Answer this question