How can I make this script so it only opens when a player is in a certain team?
I have a toggleUI remote event in replicatedstorage
This script is in the frame.
local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("ToggleUI")
local UI = script.Parent.Parent -- The frame object of THIS ui
local Debounce = true -- prevents spamming
local CloseButton = script.Parent:WaitForChild("CloseB")
CloseButton.MouseButton1Down:Connect(function()
UI.Enabled = false -- Force it to be false
end)
RemoteEvent.OnClientEvent:Connect(function()
if Debounce then
Debounce = false
UI.Enabled = not UI.Enabled -- Sets to the opposite boolean (true/false)
wait(1)
Debounce = true
end
end)
This is another script in the brick itself.
local ClickDetector = script.Parent:WaitForChild("ClickDetector")
local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("ToggleUI")
-- When a player clicks the brick, we want the UI to toggle.
ClickDetector.MouseClick:Connect(function(player)
RemoteEvent:FireClient(player) -- Only 'target' this player.
end)
Picture of Explorer: https://cdn.discordapp.com/attachments/557145682587418644/620936267173199872/Screen_Shot_2562-09-10_at_17.56.03.png