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”)
Code
local Players = game:GetService("Players")
local door = script.Parent
door.Touched:Connect(function(hit)
if hit then
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player and player.TeamColor == BrickColor.new("Really blue") then
door.CanCollide = false
wait(0.1)
door.CanCollide = true
end
end
end
Thanks for your help!