FilterEnabled and parts

To be honest, I had no clue where this topic would go. Either scripting or building but this seems more of a studio scripting problem.

So I did a little research on Roblox and Devforum on Filter Enabled and it was depreciated.

I am currently trying to make a system where you touch a part and if you have enough money, the part’s CanCollide is turned off and the player can go through but I don’t want other players to see the same thing.

How can I go to making the part’s CanCollide only visible to the player who touched it and not to the rest of the server?

Handle the Part’s Visibility on the client using a LocalScript inside StarterPlayerScripts :wink: Keeping in mind though you’ll have to implement sanity checks on the server to ensure that exploiters won’t cheat the system

So this local script will connect to the part and change the visibility/CanCollide for the client only (once they did touch it and they assumably have enough cash to be able to go through)

Correct, if you already have the script made you could just change it to a LocalScript

All you’d really need to do is reference the Part inside the workspace instead

1 Like

Thats a feature I didn’t know of! I will go test!

It’s still changing to the entire server. Here is the script thats inside StarterPlayerScripts:

local debounce = false

game.Workspace["Leaderstat Door for tutorial"].Touched:Connect(function(touched)
	local Player = game.Players:GetPlayerFromCharacter(touched.Parent)
	if not Player then return end
	if debounce == false then
		if Player.leaderstats.Money.Value >= 1000 then
			debounce = true
			Player.leaderstats.Money.Value = Player.leaderstats.Money.Value - 1000
			game.Workspace["Leaderstat Door for tutorial"].CanCollide = false
			game.Workspace["Leaderstat Door for tutorial"].Transparency = 0.5
			print(Player.DisplayName.." has went through the 100 cash door. Process complete.")
			wait(5)
			debounce = false
		else
			print(Player.DisplayName.." doesn't have enough cash!")
			wait(10)
		end
	end
end)

Did you make sure to change it into a LocalScript?

To prevent exploiters, you could make a second door inside and check if they have enough money using a server script, and if they don’t, kill them.

The one named “Money Checker” is my script Screen Shot 2021-06-03 at 4.50.04 PM

You can’t change values on the client due to filtering enabled.

Consider using a remote event to change the values

But if the player does have enough money and the part transparency changes, it changes for the entire server. I want it to change for the client only.

CanCollide is not visible to other players, they will not notice it is off/on unless they try going through

I would recommend using Collsion Filtering to utilize this.

If the player has enough money then add them to the collision group
Then you don’t have to make it a localscript

Are you checking this side if you aren’t doing so? The part should still have collisions for other players

image

I’m testing in a local server with 2 bot players so I can’t utilize that feature. I can manually test though with 2 real players but even if that’s the problem, the script should already just make it so that it changes for the client only.

The thing though, is that clients should each have individually different areas & stats so I’m unsure as to why it’s not working apart from not checking the Door on the server-side

When you mean “2” bot players, do you mean NPC’s…?

It’s in the test tab, testing on client and servers tab.Screen Shot 2021-06-03 at 5.01.40 PM

This is what I mean. Put a script in the part and insert this into it

local PhysicsService = game:GetService("PhysicsService")

local wall = "Door"
local player = "Whitelist"

--Creating collision groups
PhysicsService:CreateCollisionGroup(wall)
PhysicsService:CreateCollisionGroup(player)
--Set the two collision groups to not collide
PhysicsService:CollisionGroupSetCollidable(wall,player,false)
--Adding parts to collision group
PhysicsService:SetPartCollisionGroup(script.Parent,wall)

script.Parent.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player and player.leaderstats.Money.Value >= 1000 then
		for _,p in pairs(hit.Parent:GetChildren()) do
			if p:IsA("BasePart") then
				p:SetPartCollisionGroup(p,player)
			end
		end
		player.leaderstats.Money.Value -= 1000
		print("Successful")
	end
end)

Please note that the player can only be in one collison group at a time.

Is it possible to change the players collision group to another part if there are multiple parts like this?