So like I’m trying to make a script where you say pass or enroll (user) so like :pass blahblah123 and it make this collision of for that part
How to make a part collision off for a spicefic person script ?
1 answer
You can use LocalScripts (Client Scripts) and RemoteEvents. LocalScript runs a code only for the Client (you/LocalPlayer/the computer being used).
You may be asking: why are we gonna use Remote Events? If you're checking if a player typed a command, you will use the Server so that everyone can experience the command (and to avoid hacks). But how can we communicate with the Client? That's where RemoteEvents come in. They can send data from Server to Client and vice versa.
First, create a RemoteEvent in ReplicatedStorage and name it "PassPlayer". Next, create a script in ServerScriptService:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PassPlayer = ReplicatedStorage.PassPlayer -- the RemoteEvent
local passCommand = ":pass"
local function onJoin(player)
player.Chatted:Connect(function(message) -- when player chats
local arguments = message:split(" ") -- splitting the message by spaces
local command = arguments[1]
local targetName = arguments[2]
if (command:lower() == passCommand) and (targetName ~= nil) then -- if player used the command and put a player's username
for _, otherPlayer in ipairs(Players:GetPlayers()) do
if otherPlayer.Name:lower():find(targetName:lower()) then -- if a name of a player matched the targetName
PassPlayer:FireClient(otherPlayer) -- fires to the client of the otherPlayer
end
end
end
end)
end
Player.PlayerAdded:Connect(onJoin)
for _, player in ipairs(Players:GetPlayers()) do
coroutine.wrap(onJoin)(player)
end
Lastly, create a local script in StarterPlayerScripts (inside StarterPlayer):
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PassPlayer = ReplicatedStorage:WaitForChild("PassPlayer") -- the RemoteEvent
local Door = workspace:WaitForChild("Door") -- for example, we have a part named "Door" in workspace
PassPlayer.OnClientEvent:Connect(function()
Door.CanCollide = false
end)
1 comment
Bit overengineered - you simply could've given them a solution such as adding the character to a collision group which doesn't collide with one of the door.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Use collision groups