it’s staff only door there’s 4 teams business,comfort,economy,staff but the door doesn’t seem to work (it’s only for staff) and it’s a model and there’s a localscript inside it the localscript doesn’t have a name.
local player = game.Players.LocalPlayer
local teams = game:GetService("teams")
local TeamDoor = game.Workspace:FindFirstChild("TeamDoor")
if player.Team == teams.Business or teams["Comfort"] then
TeamDoor.CanCollide = false
end
Your script only checks the player’s team once. This is done way too early, so it’s likely that the player’s team hasn’t been set yet. Because this check is only made once, changes to a player’s team will not update their collision status with the door
put the localscript inside of PlayerGui and add this code instead:
–
local player = game.Players.LocalPlayer
local teams = game:GetService("Teams")
local TeamDoor = game.Workspace:WaitForChild("TeamDoor")
function updateDoor()
--if you want either team to make the door open?
TeamDoor.CanCollide = (player.Team == teams.Business or player.Team == teams.Comfort)
end
player.Changed:connect(function(change)
if change ~= "TeamColor" then return end
updateDoor()
end)
updateDoor()
local player = game.Players.LocalPlayer
local teams = game:GetService("Teams")
local TeamDoor = game.Workspace:WaitForChild("TeamDoor")
function updateDoor()
--if you want either team to make the door open?
TeamDoor.CanCollide = not (player.Team == teams.Business or player.Team == teams.Comfort)
end
player.Changed:connect(function(change)
warn(change)
if change ~= "TeamColor" then return end
updateDoor()
end)
updateDoor()
woah taught me something thx. And Dennis you add it like this:
local player = game.Players.LocalPlayer
local teams = game:GetService("Teams")
local TeamDoor = game.Workspace:WaitForChild("TeamDoor")
function updateDoor()
--if you want either team to make the door open?
TeamDoor.CanCollide = not (player.Team == teams.Business or player.Team == teams.Comfort)
end
player:GetPropertyChangedSignal("Team"):Connect(updateDoor)
updateDoor()
local player = game.Players.LocalPlayer
local teams = game:GetService("Teams")
local TeamDoor = workspace:FindFirstChild("TeamDoor")
local function ChangeCollisionProperty()
for _,part in TeamDoor:GetChildren() do
if part:IsA("BasePart") then
TeamDoor.CanCollide = player.Team ~= teams.Business
end
end
end)
ChangeCollisionProperty()
player:GetPropertyChangedSignal("Team"):Connect(ChangeCollisionProperty)
Try this.
As you’re a beginner, I expect you’d ask: “Where to put the script?”
Okay so, insert a local script in StarterPlayer → StarterCharacterScripts and paste this script in that newly created script.
local player = game.Players.LocalPlayer
local teams = game:GetService("Teams")
local TeamDoor = workspace:FindFirstChild("TeamDoor")
local function ChangeCollisionProperty()
for _,part in TeamDoor:GetDescendants() do
if part:IsA("BasePart") then
TeamDoor.CanCollide = player.Team ~= teams.Business
end
end
end)
ChangeCollisionProperty()
player:GetPropertyChangedSignal("Team"):Connect(ChangeCollisionProperty)
Uhm not to be rude or anything but can you read properly?
READ THIS AND DO WHAT I SAID.
Also an updated script:
local player = game.Players.LocalPlayer
local teams = game:GetService("Teams")
local TeamDoor = workspace:FindFirstChild("TeamDoor")
local function ChangeCollisionProperty()
for _,part in TeamDoor:GetDescendants() do
if part:IsA("BasePart") then
TeamDoor.CanCollide = player.Team ~= teams.Business
end
end
end
ChangeCollisionProperty()
player:GetPropertyChangedSignal("Team"):Connect(ChangeCollisionProperty)