Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I can't get a team door working. My own and online code don't work. Can anyone fix this?

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.

1 answer

try doing

if plr.Team.Name == "good" and db == false then

new approach

local debounce = false

function Touch(trigger)
   if trigger.Parent.Name == "Torso" or trigger.Parent.Name == "Left Leg" or trigger.Parent.Name == "Left Arm" or trigger.Parent.Name == "Right Leg" or trigger.Parent.Name == "Right Arm" then
  local playername = trigger.Parent

if game.Players[playername.Name].Team.Name == "good" and debounce == false then
                  debounce = true
            print ("3")
            script.Parent.CanCollide = false
            script.Parent.CanCollide = false
            script.Parent.Transparency = 0.5
            script.Parent.Transparency = 0.8
            wait(3)
            script.Parent.doorglass.CanCollide = true
            script.Parent.CanCollide = true
            script.Parent.Transparency = 0
            script.Parent.Transparency = 0.5
            debounce = false
      end
end


script.Parent.Touched:Connect(Touch) -- put this in the DOOR

16 comments

0

Ive tried that, ill try again real quick

0

alright, let me know if this one works

0

It still doesn't do the function

0

hmm let me re-check the code

0

check the full edited code script, see if that works.

0

this is what a majority of the tutorials said to do, still doesn't work

0

hangon i'll re-write one for you

0

Thanks a lot for trying to help

0

there i've written one which might work, put this in the actual DOOR part.

0

also, is doorglass inside of the door?

0

No, and the most recent one doesn't seem to work, I added a missing end and made the paths correct and still nothing

0

hmm.... Check the team capitalization is correct and the paths are correct, not sure why this isn't working now.

0

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

0

i feel like it's your games problem, not your codes problem. Keep trying and good luck.

0

And where it says "game.Players[playername.Name].Team.Name" Am I supposed to change anything? Like the word playername

0

no it shouldn't be, else it'd error nil or whatever

This discussion is preserved as it was. New answers, comments, and votes are closed.