Button disappear at different Team positions

Hey everyone I’m currently working on…nvm it’s not important but like I want the textButton appear when I’m on “Lobby” Team position and I want it to dissapear when im on “Playing” Team Position, these are like 2 different spots or sth. like that
Roblox(10)

here’s a script that may help a bit and the local script should be the child of the TextButton(TextButtonName=OpenSendTrades)

local intermission = 50
local roundLength = 180

local inRound = game.ReplicatedStorage.InRound
local staus = game.ReplicatedStorage.Status

local playingTeam = game.Teams.Playing
local lobbyTeam = game.Teams.Lobby

local murderMysteryModule = require(game.ReplicatedStorage.MurderMysterySystem)

inRound.Changed:Connect(function()

if inRound.Value == true then
	
	for i, plr in pairs(game.Players:GetChildren()) do
		
		local char = plr.Character
		local humanRoot = char:WaitForChild("HumanoidRootPart")
		
		
		
		plr.Team = playingTeam
		
		char:WaitForChild("Humanoid").Died:Connect(function()
			
			plr.Team = lobbyTeam
			
			
		end)
		
	end	
	
	
else
	
	for i, plr in pairs(game.Players:GetChildren()) do

		local char = plr.Character
		local humanRoot = char:WaitForChild("HumanoidRootPart")
		local human = char:WaitForChild("Humanoid")

		humanRoot.CFrame = game.Workspace.lobbySpawn.CFrame
		
		plr.Team = lobbyTeam
		
		human:UnequipTools()
		plr.Backpack:ClearAllChildren()
		
	end
end	

end)

local function round()
while true do

	local requiredPlayers = 2
	
	repeat
		wait(1)
		staus.Value = "Atleast ".. requiredPlayers.." players are needed to start a round"
		
	until #game.Players:GetChildren() >= requiredPlayers
	
	inRound.Value = false
	
	
	for i = intermission, 0, -1 do
		
		staus.Value = "Game will start in "..i.." seconds"
		
		wait(1)
		
	end
	
	inRound.Value = true
	
	local msg = murderMysteryModule.ChooseRoles()

	for i = roundLength, 0, -1 do
		
		staus.Value = "Game will end in "..i.." seconds"
		
		local playing = {}
		
		for i, plr in pairs(game.Players:GetChildren()) do
			if plr.Team.Name == "Playing" then
				table.insert(playing, plr.Name)
			end	
		end
		
		local MurdererAlive = false
		local NonMurdererAlive = false
		local murderer
		
		for i, playerInRound in pairs(playing) do
			
			if game.Players:FindFirstChild(playerInRound):WaitForChild("Role").Value == "Murderer" then
				MurdererAlive = true
				murderer = game.Players:FindFirstChild(playerInRound)
				
			elseif game.Players:FindFirstChild(playerInRound):WaitForChild("Role").Value ~= "Murderer" then
				NonMurdererAlive = true
			end
			
		end
		
		
		if #playing == -1 then
			
			staus.Value = "Everyone Has Died"
			
			wait(3)
			break
			
		end
		
		if MurdererAlive == true and NonMurdererAlive == false then
			staus.Value = playing[1].." The Murderer Has Won!"
			wait(3)
			break
		end
		
	    if (MurdererAlive == false and NonMurdererAlive == true) or NonMurdererAlive == true and i == 0 then
          staus.Value = playing[1].." The Innocents Have Won!"
          wait(3)
          break
     end
		
		
		
		wait(1)
	end
	wait(3)
end

end

spawn(round)

1 Like

If you want to update the visibility of a button based on a team you could do it this way


local textButton = script.Parent
local player = game.Players.LocalPlayer
local lobbyTeam = game.Teams.Lobby
local playingTeam = game.Teams.Playing

local function updateVisibility()
    if player.Team == lobbyTeam then
        textButton.Visible = true
    else
        textButton.Visible = false
    end
end

player:GetPropertyChangedSignal("Team"):Connect(updateVisibility)

updateVisibility()
2 Likes

dude it worked thank you thank you thank you

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.