Hi, i’ve been trying to fix this door but nothing has worked so far, the door is supposed to kill anyone who is not inside the security team, but it kills everyone who touches it instead, even if you are in the security team, there are no errors in the output and I don’t know what’s wrong with this script. Could someone help me?
local team1 = game.Teams.Security
local door = script.Parent
door.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr.Team == team1 then
script.Parent.Laser:Play()
else
script.Parent.Laser:Play()
humanoid.Health = 0
end
end
end)
Are you changing player’s team through a local script? if so that’s your issue. Server can not see the changes from client. You should use remote events to change the team if you’re using a local script to change team.
Yeah that’s the issue. When you change the team on a local script server won’t see it so it’s killing you because server says “you’re not in Security team”. If you use a remote event to change team you will fix it. Hope this makes sense.
It is the problem. Change the script to a ServerScript, as if you change it on the client, only the client sees it, and you check the team on the Server, which the server doesn’t see that the team is actually security.