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