I am trying to create a door that only lets one team through and blocks the other team and makes a hint when the wrong team member is trying to get through it.
This is what I have so far:
door1 = script.Parent Defender = BrickColor.new("Bright green") Raider = BrickColor.new("Bright red") function door(plr) if plr.TeamColor == Defender then door1.Transparency = 1 door1.CanCollide = false wait(2) door1.Transparency = 0.5 door1.CanCollide = true elseif plr.TeamColor == Raider then door1.Transparency = 0.5 door1.CanCollide = true r = plr.Name m = Instance.new("Hint") m.Parent = game.Workspace m.Text = r.."Is Trying To Enter The Defender Spawn!" wait(5) m:remove() end end door1.Touched:connect(door)
I am guessing that "plr" refers to the door instead of the player who touched the door. How do I refer to the player who hit the door in the function?
no plr refers to the player that goes through dooor. Its a parameter for the functioon determining if a player can pass through the door.....
function debounce(f) local d = false return function(...) if not d then d = true f(...) -- d = false end end end --[[I have no idea how to use that function but I would do,]] door1.Touched:connect((debounce(function(plr) if plr.Parent:findFirstChild("Humanoid") and game.Players:findFirstChild(plr.Parent.Name) then i = game.Players:findFirstChild(plr.Parent.Name) if i.TeamColor == Defender then door1.Transparency = 1 door1.CanCollide = false wait(2) door1.Transparency = 0.5 door1.CanCollide = true elseif i.TeamColor == Raider then door1.Transparency = 0.5 door1.CanCollide = true r = i.Name m = Instance.new("Hint") m.Parent = game.Workspace m.Text = r.."Is Trying To Enter The Defender Spawn!" wait(5) m:remove() end end end end))