I’m trying to make a main menu GUI where if you press play without picking a team the JobFrames GUI pops up, and if you select the Jobs menu in the main menu, and press play it just removes the gui
local canSpawn = Instance.new("BoolValue")
canSpawn.Name = "canSpawn"
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local items = script.Parent:GetChildren()
local plr = script.Parent.Parent.Parent.Parent
local spawns = game.Workspace.Folder:GetChildren()
for i,v in pairs(items) do
if v:IsA("TextButton") then
table.insert(newTable,v)
end
end
for i,v in pairs(newTable) do
v.MouseButton1Click:Connect(function()
local t = Teams:FindFirstChild(v.Text)
plr.Team = t
script.Parent.Parent.Frame.Visible = true
if spawns[i].TeamColor == t.TeamColor then
plr.Character:MoveTo(spawns[i].Position + Vector3.new(0,10,0))
end
end)
end
Error is on this line: if spawns[i].TeamColor == t.TeamColor then
Tried this and it worked for the one team.
Now when I try it for the other team it doesn’t change the team or tp the player to the spawner.
Both the Spawner and Team’s Team color is the same. So is the name of the button and the team name.
local newTable = {}
local canSpawn = Instance.new("BoolValue")
canSpawn.Name = "canSpawn"
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local items = script.Parent:GetChildren()
local plr = script.Parent.Parent.Parent.Parent
local spawns = game.Workspace.Folder:GetChildren()
for i,v in pairs(items) do
if v:IsA("TextButton") then
table.insert(newTable,v)
end
end
for i,v in pairs(newTable) do
v.MouseButton1Click:Connect(function()
local t = Teams:FindFirstChild(v.Text)
plr.Team = t
for i=1, #spawns do
if spawns[i].TeamColor == t.TeamColor then
plr.Character:MoveTo(spawns[i].Position + Vector3.new(0,10,0))
end
script.Parent.Parent:Destroy()
end
end)
end```
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local Plr = script:FindFirstAncestorWhichIsA("Player")
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Folder = script.Parent
local Items = Folder:GetChildren()
local SpawnFolder = workspace:WaitForChild("Folder")
local Spawns = SpawnFolder:GetChildren()
for i, v in pairs(Items) do
if v:IsA("TextButton") then
v.MouseButton1Click:Connect(function()
local Team = Teams:FindFirstChild(v.Text)
if Team then
Plr.Team = Team
for i, v in pairs(Spawns) do
if v.BrickColor == Team.TeamColor then
Char:MoveTo(v.Position + Vector3.new(0, 10, 0))
end
end
end
end)
end
end
If you need any assistance regarding understanding any of the changes I’ve implemented don’t hesitate to ask.