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

When a player changes team, I want a GUI to go invisible but it does not work?

So, I have this game where when you spawn in, you have a red and blue block GUI representing the red and blue team.

Whichever block you click on, you become apart of that team.

When you click on red for example, you die and respawn on the red team, but here's the problem.

I want it so that if you are on the red or blue team, the teamchange gui that appears when you first spawn, that should become invisible when you join one of these teams and respawn.

Here is the script I have so far.

The script I am using is inside a local script and is merged with another script I am using.

wait(1)
local blue = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Blue
local red = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Red
local player = game.Players.LocalPlayer
local gui = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame

blue.MouseButton1Click:Connect(function()
	player.TeamColor = BrickColor.new("Bright blue")
	game.Players.LocalPlayer.Character.Humanoid:TakeDamage(100)
end)

if game.Players.LocalPlayer.Team == "Blue" then
	gui.Visible = false
end

Help is appreciated!

9 comments

0

gui is nil when used outside of its scope

0

What do you mean "outside of its scope"

0

a loop block is a "scope" and that "scope" is above the local variable's "scope"

0

so the variable isn't seen

0

How do I remove the GUI when the player is on another team?

0

gui is visible in lower scopes. Please stop spreading misinformation about local variables thanks

0

Are you talking to me?

0

Just destroy the Gui. Where is the script? Is it inside the button or what?

0

Just destroy the Gui. Where is the script? Is it inside the button or what?

1 answer

Forget this. I will redo it myself.

1 comment

0

if you don't need the gui at all, then :destroy() it

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