I'm just trying to make a simple team door, that turns cancollide false and semi transparent when touched but only only when on a certain team. I am very new to scripting and might just be overlooking something obvious.
This is my code
db = false
local Teams = game:GetService("Teams")
local good = Teams.good
function OnTouched(hit)
print ("1")
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
print("2")
if plr.Team == game.Teams.good and db == false then
db = true
print ("3")
script.Parent.doorglass.CanCollide = false
script.Parent.door.CanCollide = false
script.Parent.door.Transparency = 0.5
script.Parent.doorglass.Transparency = 0.8
wait(3)
script.Parent.doorglass.CanCollide = true
script.Parent.door.CanCollide = true
script.Parent.door.Transparency = 0
script.Parent.doorglass.Transparency = 0.5
db = false
end
end
end
script.Parent.door.Touched:connect(OnTouched)
some things might be messed up from me trying to get it to work for so long
There are no errors but it just doesn't work, and when I put it to plr.Name = "bat11194" (my name) it works, so I have no idea why it doesn't work for teams. I've also straight pasted code from countless tutorials and forums online and none of them work. Please help.

16 comments
Ive tried that, ill try again real quick
alright, let me know if this one works
It still doesn't do the function
hmm let me re-check the code
check the full edited code script, see if that works.
this is what a majority of the tutorials said to do, still doesn't work
hangon i'll re-write one for you
Thanks a lot for trying to help
there i've written one which might work, put this in the actual DOOR part.
also, is doorglass inside of the door?
No, and the most recent one doesn't seem to work, I added a missing end and made the paths correct and still nothing
hmm.... Check the team capitalization is correct and the paths are correct, not sure why this isn't working now.
I am very confused as well, I've made sure its correct and it is not even printing 3. I have no idea what could be wrong
i feel like it's your games problem, not your codes problem. Keep trying and good luck.
And where it says "game.Players[playername.Name].Team.Name" Am I supposed to change anything? Like the word playername
no it shouldn't be, else it'd error nil or whatever