Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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!

1 comment

0

You could place the wall in everyone's Camera and manipulate it accordingly to each client.

2 answers

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

What he said ^^^^^^^

5 comments

1

You cant use localparts, as the SERVER has to see the part, but the PLAYER doesnt. Also, make this a comment.

1

Ruben, the hell are you talking about?

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.

0

Okay. That makes more sense. That part was difficult to understand in the question.

This discussion is preserved as it was. New answers, comments, and votes are closed.