How to add an invisible map borders (completely ghostly)?

So I have a little map, its borders were just very tall invisible walls, however those walls caused many issues, for example when I a player is standing near the wall and tries to shoot the mouse.Hit.Position returns direction to the wall instead of the actual player he is shooting at
Besides I have some teleport tools in my game, players were able to use them to get on the invisible wall, I tried to damage players who stay on top but then realised that this is not correct, if a player threw an end pearl and it hit the invis wall they will get teleported up, it’s unfair to kill them

So I was just asking, is there any way to create a COMPLETELY GHOSTLY wall that can’t be clicked, bullets and enderpearls will go through, will be dealt as nothing or nil, but just prevents the player from jumping off the cliff of the map?

1 Like

Change the invisible wall’s CollisionGroupId to 3. This will allow parts to go through it but players will collide.

Tested it out but sadly didn’t work, thanks for helping tho!

Restrict camera movement so that a player can’t scroll out beyond the invisible walls, otherwise when they shoot then the mouse object of the player will think that the target is one of those invisible walls other than the player/part that they are actually aiming at.

As @DesertusX stated you can use Collision Filtering | Roblox Creator Documentation but you can’t just change the CollisionGroupId to 3, you have to set up a couple of groups as shown in the link I provided.
Also here’s a way to put players into CollisionGroups Collision Filtering | Roblox Creator Documentation since they have to be added to the CollisionGroup when they join the game.

1 Like

alright, I will check it and try, but will this work for mouse.Hit.Position too ro I have to go with Limited_Unique solution?

If you don’t want them to affect mouse.Hit.Position, you can put them all in a model and set that model as the mouse’s target filter.

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse() --Yes I know this is deprecated
mouse.TargetFilter = --The model

Here’s the page for mouse.TargetFilter: Mouse | Roblox Creator Documentation

You could go with @Limited_Unique’s solution too though.

3 Likes

https://developer.roblox.com/en-us/api-reference/property/Player/CameraMinZoomDistance
https://developer.roblox.com/en-us/api-reference/property/Player/CameraMaxZoomDistance
https://developer.roblox.com/en-us/api-reference/property/Mouse/TargetFilter

These are you best options.

1 Like

Perfect solution for mouse.Target, thanks alot for helping

Ya, third one was the best out of them, I will still use the first two for other features in my game, thanks alot!

Ok here is how I got it to work, maybe help someone in the future
every part has collision of 0 by default
every part in the player collision group is set to 2 in player.Character.CharacterAdded event
for _, p in pairs(chara:GetChildren()) do if p:IsA('BasePart') then PS:SetPartCollisionGroup(p, 'Players') end end
Wall collision group is set to 1 (manually, or automatic if you want)

finally the collision group shoul look like thisScreen Shot 2021-11-11 at 6.57.55 PM

I wish I could accept multiple answers, it’s now a completely ghostly wall, thanks so much guys

And lemme add a third answer, Set CanTouch to false

My bad. I just found out that just changing the CollisionGroupId to 3 only works in a kit that I was using.

1 Like

Well, you made the way I should follow pretty clear, all what it required was little searches. Thanks a lot!

1 Like