Why isn't this simple team-only door script working?

I want to start off by saying I’m by no means a scripter, so this might be an incredibly simple issue.

I’m building a skirmish area for my training base, and to stop spawn-campers, I’ve added a wall with a script that only allows people of the same team in. However, even if you’re on the correct team, the script doesn’t seem to be working.

I took this directly from a Dev Hub tutorial and only slightly modified it. Dev Hub link.

I’ve triple-checked, and the wall does match up with the spawn points. (People on the blue team are hitting the wall with a script that says, player and player.TeamColor == BrickColor.new(“Really blue”)

local Players = game:GetService("Players")
local door = script.Parent
		if hit then
			local player = Players:GetPlayerFromCharacter(hit.Parent)
			if player and player.TeamColor == BrickColor.new("Really blue") then

				door.CanCollide = false 

				door.CanCollide = true

Images for Refrence

(The wall)

image (Teams)

(Me hitting the wall on the blue team.)

Thanks for your help!


I believe the actual touch function is working , test by placing print(“test”) after:

if player and player.TeamColor == BrickColor.new("Really blue") then

(Then check if “Test” printed in the output)

I think the issue is that you don’t have a long enough wait

Also the Debounce part in the dev wiki (dev hub) code, is pretty important most of the time

1 Like

if i were you i would find the player by using the hit.parents (provided it IS in hit.parent, but that comes after) name

now to that part, you should have a seperate check for hats, and also increase the wait to about 2 seconds (some people wont be able to do stuff properly due to latency issues)


Oh, I’m really dumb. :joy:

I forgot to add a closed parentheses at the end of the last end.

I’ve also changed the wait time to two seconds, to help with latency.

Thanks, everyone!