So short said. I’m making a bunch of doors that have different settings and I want specifically on this door to fire for all staff personnel. The script works fine in a normal script and instead of
Door1.Part.ClickDetector
It would be
script.Parent.Part.ClickDetector
where as this works fine.
Now I put this in serverscriptservice and tagged everything as it should be tagged with StaffDoorR1 for specifying one type of rotation where as another StaffDoorR2 is for another rotation since doors rotate differently depending on where they are.
Right now I can’t get it to fire when I make a script and do this:
local CollectionService = game:GetService("CollectionService")
local Unauth = game.Teams.Patient.TeamColor
local Max = game.Teams["Max Security Patient"].TeamColor
for _,Door1 in pairs(CollectionService:GetTagged("StaffDoorR1")) do
local Cooldown = 0
local Knock = Door1.Center.Knock
local Timer = Door1.Timer
Door1.Part.ClickDetector.MouseClick:Connect(function(Player)
if Player.TeamColor == Unauth and Cooldown == 0 or Player.TeamColor == Max and Cooldown == 0 then
Cooldown = 5
Knock:Play()
wait(2)
Cooldown = 0
elseif Player.TeamColor == Unauth and Cooldown == 5 or Player.TeamColor == Max and Cooldown == 5 then
return
else
local Mag = (script.Parent.Center.Position-Player.Character.HumanoidRootPart.Position).magnitude
if Mag <= script.Parent.Range.Value then
if Can then
Can = false
if Open == false then
local finish = script.Parent.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
for i = 0,1,.1 do
local cfm = script.Parent.PrimaryPart.CFrame:lerp(finish,i)
script.Parent:SetPrimaryPartCFrame(cfm)
wait()
end
Open = true
Timer.Value = 10
else
Open = false
local finish = script.Parent.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
for i = 0,1,.1 do
local cfm = script.Parent.PrimaryPart.CFrame:lerp(finish,i)
script.Parent:SetPrimaryPartCFrame(cfm)
wait()
end
end
Can = true
end
end
end
end)
while true do
while Timer.Value > 0 do
Timer.Value = Timer.Value - 1
wait(1)
end
if Open == true and Timer.Value == 0 then
Open = false
local finish = script.Parent.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
for i = 0,1,.1 do
local cfm = script.Parent.PrimaryPart.CFrame:lerp(finish,i)
script.Parent:SetPrimaryPartCFrame(cfm)
wait()
end
Can = true
end
wait()
end
end
The “unauth” and “max” is 2 teams that shouldn’t be allowed to use the door and instead makes a knock which has been working very fine with a normal script in the door.
There are different doors but they all fire the same way and I can’t make it work the way it should, can anyone help ?