Team only proximity prompt?

Is there a way I can make this dialog script only work for one team. I called the team function but cant seem to get any kind of restriction for checking the team before activating the prompt.

local say = {"test."}

local debounce = false
local sound = script.Parent.Tool.Handle.talk
local prompt = script.Parent.ProximityPrompt
local clicksound = script.Parent.Tool.Handle.click
local Teams = game:GetService("Teams")
local team = Teams["team1"]

local hasClicked = false

game.ReplicatedStorage.DetectClick.OnServerEvent:Connect(function()
	hasClicked = true
end)

prompt.Triggered:Connect(function(plr)
	if plr.PlayerGui.NpcChatGui.Enabled then return end
	sound:Play()
	plr.PlayerGui.NpcChatGui.NpcName.Text = script.Parent.Name
	plr.PlayerGui.NpcChatGui.Enabled = true
	for i, v in pairs(say) do
		hasClicked = false
		for i = 1, string.len(v) do
			plr.PlayerGui.NpcChatGui.NpcText.Text = string.sub(v, 1, i)
		end
		while wait() do
			if hasClicked then
				clicksound:Play()
				break
			end
		end
	end
	plr.PlayerGui.NpcChatGui.Enabled = false
end)
1 Like

Do you want something like this? Where it checks for the team before working??

if Player.Team = team then 

end

Yes exactly, but I cant get it to work properly

How about making the prompt not trigger if the players team isn’t equal to the team you want?

2 Likes

Like this?

local say = {"Test"}

local debounce = false
local sound = script.Parent.Tool.Handle.talk
local prompt = script.Parent.ProximityPrompt
local clicksound = script.Parent.Tool.Handle.click
local Teams = game:GetService("Teams")
local team = Teams["team1"]

local hasClicked = false

game.ReplicatedStorage.DetectClick.OnServerEvent:Connect(function()
	hasClicked = true
end)


prompt.Triggered:Connect(function(plr)
	
	if plr.Team ~= team then return end
	
	if plr.PlayerGui.NpcChatGui.Enabled then return end
	sound:Play()
	plr.PlayerGui.NpcChatGui.NpcName.Text = script.Parent.Name
	plr.PlayerGui.NpcChatGui.Enabled = true
	for i, v in pairs(say) do
		hasClicked = false
		for i = 1, string.len(v) do
			plr.PlayerGui.NpcChatGui.NpcText.Text = string.sub(v, 1, i)
		end
		while wait() do
			if hasClicked then
				clicksound:Play()
				break
			end
		end
	end
	plr.PlayerGui.NpcChatGui.Enabled = false
end)