Disabling Proximity Prompt for a Team?

Hey, I’m trying to make a Prison game where if your an Inmate the Proximity Prompt gets disabled for the opening/closing of the door and for Police the Proximity Prompt is enabled. I have multiple doors with the same name and I’m trying to make 1 script target all of those doors. I’m super new to Scripting but this is what I so far.

local Player = game.Players.LocalPlayer

if Player.TeamColor == BrickColor.new("Dark blue") then

    for index, object in next, game.Workspace:GetChildren() do
	
	    if object:IsA('ProximityPrompt') then
	
	       if object.Name == 'DoorPrompt' then

             object.Enabled = true

		elseif Player.TeamColor == BrickColor.new("Deep orange") then
			
			for index, object in next, game.Workspace:GetChildren() do

				if object:IsA('ProximityPrompt') then

					if object.Name == 'DoorPrompt' then

						object.Enabled = false
						
					end
				end
			end
		end
	end
end

end

3 Likes

Are there any errors in the output?

local Player = game.Players.LocalPlayer
if Player.TeamColor == BrickColor.new("Dark blue") then

    for index, object in next, game.Workspace:GetDescendants() do
	
	    if object:IsA("ProximityPrompt") then
	
	       if object.Name == "DoorPrompt" then

             object.Enabled = true

           end
        end
	end

	elseif Player.TeamColor == BrickColor.new("Deep orange") then
			
			for index, object in next, game.Workspace:GetDescendants() do

				if object:IsA('ProximityPrompt') then

					if object.Name == 'DoorPrompt' then

						object.Enabled = false
					end
				end
			end
	end
3 Likes

Yeah, that doesn’t seem to work.

Did you use the updated code? I updated it recently. Also, make sure it’s a localscript and it’s somewhere like startergui and not workspace or serverscriptservice

2 Likes

Alright, it works I appreciate it.

Even if the prompt is disabled, an exploiter can still activate it. Make sure to have a check on the server to see if the user activating it is in the correct team as well.

1 Like

Even better, delete it and add it back.

Alright, and how would I do that?

In the server script that opens the door, check if the player activating it is in a certain team. Example:

local Teams = game:GetService("Teams")

Prompt.Triggered:Connect(function(plr)
    if plr.Team == Teams["team_name"] then 
        -- code to open door
    end
end)
2 Likes

Great, works great thanks for the help.

1 Like