Hello, I am currently working on a door for prison game where if you are a cop it opens up but if you are a prisoner or criminal it makes a doorknob sound.
For some reason, when I use the door as a prisoner it opens up and the same thing happens as a cop.
I’ve looked at some discussions on scripting helpers and some on here but it still hasn’t solved my problem.
Here is the code:
local cd = script.Parent
local door = cd.Parent.Parent.Door
local function onClick(player)
if player.Team == game:GetService("Teams").Prisoner then
workspace.Sounds.doorknob:Play()
print("they are a prisoner or criminal")
else
door.Transparency = 1
door.CanCollide = false
wait(2)
door.Transparency = 0
door.CanCollide = true
print("they are a cop")
end
end
cd.MouseClick:Connect(onClick)
It is a server script. I tested out the debug script you gave me and it printed “Guard” when I was on the guard team but when I switched to the prisoner team it printed guard again.
Well I don’t have a team change GUI, I’m just using the teamcolor property inside of my player instance in the players service and I think it does the same as a team change GUI would.
It’s an issue regarding checking if the player is on the prisoner’s team (if player.Team == game:GetService("Teams").Prisoner then). You can attempt checking for the TeamColor, followed by the prisoner’s colour, and see if that makes a change.
I think I found out the error but it works now anyways so I will just say what I think was going wrong.
Basically I was changing the team from the client’s side instead of the server’s side and now it prints that I am on the prisoner team when I am on the prisoner team instead of saying I am a guard.