How do i make something collidable on only one client?
This can be done by turning on FilteringEnabled and possibly using RemoteEvents, depending on what you're trying to do. If you're trying to make an owner only door or something then it can be done without remote events. That is the LocalScript below.
local OwnerId = 0 local Part = workspace.Part if game.Players.LocalPlayer.UserId == OwnerId then Part.CanCollide = false end
Things get a little more complex if you're looking to make a door that the server tells the client to open. This requires putting a RemoteEvent
in ReplicatedStorage
. I would recommend naming it OpenDoor or something similar. The server will run the below code to tell the client to manipulate the door.
game:GetService("ReplicatedStorage").OpenDoor.FireClient(playerInstance, true) -- Opens it game:GetService("ReplicatedStorage").OpenDoor.FireClient(playerInstance, false)
The client would use the LocalScript below to react to the server's request:
function ManipulateDoor(f) local p = workspace.Part if f == true then p.CanCollide = false elseif f == false then p.CanCollide = true end end game:GetService("ReplicatedStorage").OnClientEvent(ManipulateDoor)
I hope my answer was able to solve your problem. If it did, please remember to mark it as correct!