Hi! How can I make it so only Staff team can go to the and Economy, Business, Comfort can’t go inside the door
script.Parent.Touched:Connect(function(hit)
local Plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if Plr then
if Plr.Team == game.Teams.Staff then
script.Parent.CanCollide = false
end
end
end)
Always use game:GetService, in this case game:GetService(“Players”)
For your script, can you specify what do you mean by “only Staff team can go to the and Economy, Business, Comfort can’t go inside the door”? Staff cannot enter economy, business and comfort or can?
You can assign them to a Collision Group. You can create a new group from the Collision Groups editor (Model > Collision Groups), create a new group, and set it so the group cannot collide with itself.
If you want the group to collide with other staff, but not the door, you have to make another collision group for just the door as well.
-- This can be put into ServerScriptStorage, since it's probably better to have this script only happen once
local PlayerService = game:GetService("Players")
PlayerService.PlayerAdded:Connect(function(player: Player)
-- Check if they're staff here...
player.CharacterAdded:Wait()
local Character = player.Character
for _, Descendant in Character:GetDescendants() do
if not Descendant:IsA("Part") then continue end
Descendant.CollisionGroup = "Admin"
end
end)
-- The door itself doesn't need a script now, but here's the code if you'd like anyways
script.Parent.CollisionGroup = "AdminDoor"
If im correct, this should be a server script. You would need to send information using a remote event to that player, so it only turns off CanCollide for him. The remote event should be fired to a local script which should be located in StarterGUI, StarterCharacterScripts or StarterPlayerScripts.