local team = game.Teams.Police
local door = script.Parent
door.Touched:connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr.Team == team then
door.CanCollide = false
door.Transparency = .5
wait(1)
door.CanCollide = true
door.Transparency = 0
end
end
end)
COMMUNITY QUESTION
Is there anything wrong with the script cuz prisoners could g through the door please chek?
2 answers
Your code looks right, but I just add an else to make it teleport the prisoner back.
local team = game.Teams.Police
local door = script.Parent
door.Touched:connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr.Team == team then
door.CanCollide = false
door.Transparency = .5
wait(1)
door.CanCollide = true
door.Transparency = 0
else
plr.Character.HumanoidRootPart.Position = plr.Character.HumanoidRootPart.Position + Vector3.new(0,3,0) --//Depending on which side the door is facing, if it teleports you into a wall, just change the 2 to -2, which will cause you teleport the other way
end
end
end)
local door = script.Parent
local police = game.Teams.Cops
local prisoners = game.Teams.Prisoners
door.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player.Team == police then
door.CanCollide = false
door.Transparency = 0.6
wait(2.75)
door.CanCollide = true
door.Transparency = 0
end
end
end)
The code above checks if a player hit the door, and if they are on the police team, if they are on the police team then the door's CanCollide property is set to false and then 2.75 seconds after that the door's CanCollide property is set to true. If a prisoner touches the door it does nothing.
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
Put your code in code lines.
Edit it
I did
No you didnt
Now he did
LOL