Hello!
First off, sorry for my messy script haha.
I'm getting the following error:
23:48:59.571 - Players.7z99.PlayerGui.ScreenGui2.Frame.TextLabel.TextLabel_Roundify_12px.TextLabel.LocalScript:39: attempt to index nil with 'Name'
and I'm not sure why.
Script where the global variable is declared and given a value:
function eliminatePlayer()
local smallestValue = math.huge
_G.smallestPlayer = nil
local playingList = game.Teams.Playing:GetPlayers()
local playerTable = {}
for i, v in pairs(playingList) do
table.insert(playerTable, playingList[i].Name)
print(playingList[i].Name)
end
for i, v in pairs(playerTable) do
local currentPlayer = game.Players:FindFirstChild(v)
if currentPlayer.PlayerGui.ScreenGui.ProgressBar.Config.Progress.Value < smallestValue then
_G.smallestPlayer = currentPlayer
smallestValue = currentPlayer.PlayerGui.ScreenGui.ProgressBar.Config.Progress.Value
print(smallestValue)
end
print(_G.smallestPlayer)
end
for i,v in pairs(playerTable) do
if v == _G.smallestPlayer then
table.remove(playerTable, i)
end
end
_G.smallestPlayer.Team = game.Teams.Lobby
game.Players[_G.smallestPlayer.Name]:LoadCharacter()
for i,v in pairs(game.Teams.Complete:GetPlayers()) do
print(v)
v.Team = game.Teams
v:LoadCharacter()
end
FireClient()
waitRoundOver()
end
Here's the script where I'm trying to access the global variable, but is outputting the error:
function plrrmv(player)
local splayer = _G.smallestPlayer
print("player remove") -- it is printed, so this is being executed.
wait()
local newpos = UDim2.new(0.5, 0, 0.5, 0)
local oldpos = UDim2.new(0.5, 0, 2, 0)
script.Parent.Parent:TweenPosition(newpos, Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.5)
wait(.1)
local playerUsername = game.Players.LocalPlayer.Name
--oblox services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--equire module
local TypeWriter = require(ReplicatedStorage:WaitForChild("TypeWriter"))
TypeWriter.typeWrite(script.Parent, "Round Over! "..splayer.Name.."was eliminated!")
wait(2)
script.Parent.Parent:TweenPosition(oldpos, Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.5)
end

5 comments
That's not the problem though, it's with the global variables.
They are near the bottom of the first script.
On line 40, use TeamColor.
_G.smallestPlayer.TeamColor = BrickColor.new("Put the colour of the Lobby team here")
I’m not looking for feedback, I’m looking to make my scripts work.