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

How do I make a team-only door?

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?

1 comment

0

didnt work

2 answers

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.....

2 comments

0

Okay thanks.

0

I kind of fixed that in my answer cx





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))

3 comments

0

Er I tried that and it is still not working.

0

Oh I know the problem, I'll edit it.

0

There I edited the answer.

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