Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make a Team Door work correctly?

Hey, I've been trying to make a door that if you pass through it and you are not a specific team, it kills you. Everything I do doesn't work and there are no models of it. If someone could please tell me how I'l be really thankful.

1 answer

Try this, haven't tested it though.

-- Put this in the door PART not model

local Debounce = false -- prevent opening too much

local ForTeam = BrickColor.new("Bright red") -- replace bright red with team color name
local OpenTime = 0.5 -- open time

script.Parent.Touched:connect(function(touchedpart) -- once touched
	if touchedpart.Parent:IsA("Model") then -- if it is indeed a model
		if touchedpart.Parent:FindFirstChild("Humanoid") then -- if model has humanoid
			local Player = game.Players:GetPlayerFromCharacter(touchedpart.Parent) -- attempt to get player from model
			if Player then -- if it is a player
				if Player.TeamColor ~= ForTeam then -- if player not in correct team
					touchedpart.Parent:BreakJoints() -- kills the trespasser
				else -- if player is in team
					if Debounce == false then
						Debounce = true
						local OriginalTransparency = script.Parent.Transparency
						script.Parent.Transparency = 0.3
						script.Parent.CanCollide = false
						wait(OpenTime)
						script.Parent.Transparency = OriginalTransparency
						script.Parent.CanCollide = false
						Debounce = false
					end
				end
			end
		end
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.