Team ClickDetector Door

this wont work whats the issue

  • Objective: Click a button and the door collision changes for a certain team.
local button = script.Parent.ClickDetector
local teams = game:GetService("Teams")
local open = false

button.MouseClick:Connect(function(player)
	if open == false and player.Team.Name == "DOC" then
			script.Parent.Parent.Union.CanCollide = false
			wait(0.9)
			script.Parent.Parent.Union.CanCollide = true 
		open = not open -- If true, make false. If false, make true.
		print("open door")
	else 
		if open == true and player.Team.Name == "DOC" then
		script.Parent.Parent.Union.CanCollide = true
					wait(0.9)
			script.Parent.Parent.Union.CanCollide = false 	
			open = not open -- If true, make false. If false, make true.
			print("close door")
		end
	end
end)

There is a lack of info regarding the issue.

What exactly isn’t happening. (Door not opening/closing? Not checking team?)

And are there any error messages or warnings for this script.

1 Like

No errors, it won’t open/close if your on the DOC Team.

Here’s A version with some prints. Give it a go and see which path it takes.
This will show you how far the script makes it. I’ve got a feeling but I would like to confirm with these prints.

If everything prints and there’s no errors than I would think that the issue would be too low of a wait time.

(Let me know the output)

local button = script.Parent.ClickDetector
local teams = game:GetService("Teams")
local open = false

button.MouseClick:Connect(function(player)
	print("ClickOperated by " .. player)
	if open == false and player.Team.Name == "DOC" then
		print("Got Past if 1")
		script.Parent.Parent.Union.CanCollide = false
		wait(0.9)
		script.Parent.Parent.Union.CanCollide = true 
		open = not open -- If true, make false. If false, make true.
		print("open door")
	else 
		if open == true and player.Team.Name == "DOC" then
			print("Got Past if 2")
			script.Parent.Parent.Union.CanCollide = true
			wait(0.9)
			script.Parent.Parent.Union.CanCollide = false 	
			open = not open -- If true, make false. If false, make true.
			print("close door")
		end
	end
end)
1 Like