So my problem is basically that when I try to run the stop function I get the error “unknown global”
Can someone help me with this?
local round = game.ReplicatedStorage.round
local games = game.ServerStorage.minigames:GetChildren()
local minitime = game.ReplicatedStorage.minitime
local mininame = game.ReplicatedStorage.mininame
local stat = game.ReplicatedStorage.gamestatus
local death = game.ServerScriptService.dead
death.Enabled = false
local function start()
local mgame = games[math.random(#games)]
local gameclone = mgame:Clone()
gameclone.Parent = workspace
print(mgame)
minitime.Value = gameclone.Time.Value
mininame.Value = gameclone.Name
task.wait(.5)
for _, plr in pairs(game.Players:GetChildren()) do
plr.Character.Humanoid.Sit = false
plr.Team = game.Teams.Playing
death.Enabled = true
wait(.01)
plr:LoadCharacter()
end
round.Value = true
local function stop()
gameclone:Destroy()
for _, plr in pairs(game.Players:GetChildren()) do
plr:LoadCharacter()
end
round.Value = false
death.Enabled = false
end
end
while true do
for i = 15, 0, -1 do
stat.Value = "Intermission: " .. i
wait(1)
end
start()
for i = minitime.Value, 0, -1 do
script.Parent.towel.Text = mininame.Value .. ": " .. i
wait(1)
end
stop()
end
Your stop function is inside the start function so it’s limited to that scope meaning that you can’t call it outside, but you did call it (before last line) which is what’s causing the error.
local Rep = game:GetService("ReplicatedStorage")
local SS = game:GetService("ServerStorage")
local SSS = game:GetService("ServerScriptService")
local round = Rep.round
local minitime = Rep.minitime
local mininame = Rep.mininame
local stat = Rep.gamestatus
local games = SS:WaitForChild("minigames"):GetChildren()
local death = SSS.dead
since there’s only 3 i don’t see how it’s hard to understand what rep, ss, and sss means
he could change the names to something that’s easier to understand
3 is larger than 0.
Having names like “sss” makes the code confusing, if someone’s new to Roblox Studio and reads codes like this, there is absolutely no way he will understand what each of them mean, but if you write something like “serverScriptService”, they code easily guess what that variable is.
That was just a recommendation for better code nothing else.
“ServerScriptService” is still long so there would be no point in shortening that part of the code (imo) that’s why i would go for a shorter name
and again i still don’t see how it’s hard to figure out that SSS means ServerScriptService when it’s on the same line
You wouldnt have a Variable with A Huge name, it makes your code look weird, like for Example:
local ExampleOfALongVariableThatCanBeShortened = 10
-- for readability sake, please shorten your variables
-- so you dont haave to look at an entire sentence
-- to understand your code.
-- if you need help determining which is which
-- use a comment, not that hard.
-- you dont need to use it if you can tell
-- the Path the Variable is assigned to.
local SSS = game.ServerScriptService -- Easy to Determine what it is by looking at what it is assigned
Well, when I try to move the stop function outside of the start function I can’t access the gameclone variable, so how would I be able to reference it in another function?