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
1 Like
Hey, First you gotta give your Monster a Part that could be anything just something to tell the script it’s a monster.
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if not hit.Parent:FindFirstChild("Zombie") then - Checking for Monster Part
script.Parent.CanCollide = false
wait(0.1)
script.Parent.CanCollide = true
end
end
end)
1 Like
Implementation using PhysicsService:
--Script inside ServerScriptService
local PhysicsService = game:GetService("PhysicsService")
local Players = game:GetService("Players")
--your wall reference
local Wall = workspace.Wall
--setting up collision group for wall
PhysicsService:CreateCollisionGroup("wall")
PhysicsService:CollisionGroupSetCollidable("wall", "wall", false)
PhysicsService:SetPartCollisionGroup(Wall, "wall")
function CharacterAdded(char)
for _, part in pairs(char:GetChildren()) do
--if the part isn't an actual part, skip it
if not part:IsA("BasePart") then continue end
PhysicsService:SetPartCollisionGroup(part, "wall")
end
char.DescendantAdded:Connect(function(part)
--if a new part is added(say for example a tool handle, also include it)
if part:IsA("BasePart") then
PhysicsService:SetPartCollisionGroup(part, "wall")
end
end)
end
function PlayerAdded(player)
CharacterAdded(player.Character or player.CharacterAdded:Wait())
player.CharacterAdded:Connect(CharacterAdded)
end
for _, player in pairs(Players:GetPlayers()) do
PlayerAdded(player)
end
Players.PlayerAdded:Connect(PlayerAdded)
4 Likes
where should the script go?
^^^^^^^^^^^^^^
1 Like
just make it a normal script inside the part
Use Collision groups instead it’s alot more efficient and doesn’t require checking the wall for being touched
2 Likes
Where do i put the script for collision groups though???
- This is an entire code snippet.
- Physics service is something very useful best to learn it early
- This is the forums he asked for help I provided, what you provided could allow the monster through if there’s server lag or the monster is running against the wall.
1 Like
I’m not a beginner I just suck at using roblox’s features
1 Like
Place it in server Script service and every time the monster is picked run it to apply the collision group to the monster.
Okay sorry for stupidity i suck at collision groups
1 Like
It’s alright we all have to learn some day!