Hello, So I’m trying to make a wall that a player can go through but not a monster via collision filtering but it wouldn’t work
Please elaborate, saying something didn’t work is never enough information for me and most developers.
place a string value inside the monster, name it “NoEnter” or something, then when someone touches the part, check if they have the value, if they don’t, let them through, if they do, don’t
Or you could reverse it and put it in the player and let them through if they have it, and stop them if they don’t.
this is a sample script, you can do whatever with it
local PhysicsService = game:GetService("PhysicsService")
local obstacles = "Obstacles"
local greenObjects = "GreenObjects"
-- Create two collision groups
PhysicsService:CreateCollisionGroup(obstacles)
PhysicsService:CreateCollisionGroup(greenObjects)
-- Add an object to each group
PhysicsService:SetPartCollisionGroup(workspace.Obstacle1, obstacles)
PhysicsService:SetPartCollisionGroup(workspace.GreenBall, greenObjects)
PhysicsService:CollisionGroupSetCollidable(greenObjects, obstacles, false)
if you want to be able to do it on players, try reading and dissecting more from the information this page provides Player-Player Collisions
This was a bit confusing to write but it 100 percent works, just make sure to put the walls you want the player to be able to go through in the table. Here’s the script.
-- Put this as a Server Script in the ServerScriptService.
while true do
walls = {game.Workspace.Wall, game.Workspace.Wall2} -- These parts are examples, put the walls you want in the table.
c = game.Players:GetChildren()
for i = 1, #c do
if c[i].Character ~= nil and c[i].ClassName == "Player" then
g = c[i].Character:GetChildren()
for h = 1, #g do
if g[h]:IsA("BasePart") then
for x,l in ipairs(walls) do
if g[h]:FindFirstChildOfClass("NoCollisionConstraint") and g[h]:FindFirstChildOfClass("NoCollisionConstraint").Part1 == l then return end -- if they already have a "NoCollisionConstraint" for this wall.
local NoCollision = Instance.new("NoCollisionConstraint")
NoCollision.Part0 = g[h]
NoCollision.Part1 = l
NoCollision.Parent = g[h]
end
end
end
end
end
wait(0.1) -- change this to how long it waits before it checks if the player can collide with the wall again.
end
I’d do something like this to filter it out:
local getPlayerFromCharacter = game.Players:GetPlayerFromCharacterAsync(hit.Parent)
if not getPlayerFromCharacter then return nil end
-- Rest of the code here
Might not be detailed, but it is something.