I'm making a military themed game that has the ranks saved in the game code. and I have this leaderboard script:~~~~~~~~~~~~~~~~~
game.Players.PlayerAdded:connect(function(p)
local stats = Instance.new("StringValue")
stats.Name = "leaderstats"
stats.Parent = p
local rank = Instance.new("StringValue")
rank.Name = "Rank"
rank.Value = "REC"
local reg = Instance.new("StringValue")
reg.Name = "Regiment"
reg.Value = "No-Reg"
--ranks--
PVT = {}
LCPL = {}
CPL = {}
SGT = {}
SSGT = {}
WOC2 = {}
WOC1 = {}
LT = {}
CPT = {}
MAJ = {}
LTCOL = {}
COL = {}
BRIG = {}
MAJGEN = {}
LTGEN = {}
GEN = {}
FM = {"wexabite"}
--regiments--
RIFLES = {}
RGG = {}
SAS = {}
AAC = {}
PARAS = {}
ETS = {}
for i=1, #RIFLES do
if RIFLES[i] == game.Players.LocalPlayer.Name then
reg.Value = "RIFLES"
end
end
for i=1, #RGG do
if RGG[i] == game.Players.LocalPlayer.Name then
reg.Value = "RGG"
end
end
for i=1, #SAS do
if SAS[i] == game.Players.LocalPlayer.Name then
reg.Value = "SAS"
end
end
for i=1, #AAC do
if AAC[i] == game.Players.LocalPlayer.Name then
reg.Value = "AAC"
end
end
for i=1, #PARAS do
if PARAS[i] == game.Players.LocalPlayer.Name then
reg.Value = "PARAS"
end
end
for i=1, #ETS do
if ETS[i] == game.Players.LocalPlayer.Name then
reg.Value = "ETS"
end
end
for i=1, #PVT do
if PVT[i] == game.Players.LocalPlayer.Name then
rank.Value = "PVT"
end
end
for i=1, #LCPL do
if LCPL[i] == game.Players.LocalPlayer.Name then
rank.Value = "LCPL"
end
end
for i=1, #CPL do
if CPL[i] == game.Players.LocalPlayer.Name then
rank.Value = "CPL"
end
end
for i=1, #SGT do
if SGT[i] == game.Players.LocalPlayer.Name then
rank.Value = "SGT"
end
end
for i=1, #SSGT do
if SSGT[i] == game.Players.LocalPlayer.Name then
rank.Value = "SSGT"
end
end
for i=1, #WOC2 do
if WOC2[i] == game.Players.LocalPlayer.Name then
rank.Value = "WOC2"
end
end
for i=1, #WOC1 do
if WOC1[i] == game.Players.LocalPlayer.Name then
rank.Value = "WOC1"
end
end
for i=1, #LT do
if LT[i] == game.Players.LocalPlayer.Name then
rank.Value = "LT"
end
end
for i=1, #CPT do
if CPT[i] == game.Players.LocalPlayer.Name then
rank.Value = "CPT"
end
end
for i=1, #MAJ do
if MAJ[i] == game.Players.LocalPlayer.Name then
rank.Value = "MAJ"
end
end
for i=1, #LTCOL do
if LTCOL[i] == game.Players.LocalPlayer.Name then
rank.Value = "LTCOL"
end
end
for i=1, #COL do
if COL[i] == game.Players.LocalPlayer.Name then
rank.Value = "COL"
end
end
for i=1, #BRIG do
if BRIG[i] == game.Players.LocalPlayer.Name then
rank.Value = "BRIG"
end
end
for i=1, #MAJGEN do
if MAJGEN[i] == game.Players.LocalPlayer.Name then
rank.Value = "MAJGEN"
end
end
for i=1, #LTGEN do
if LTGEN[i] == game.Players.LocalPlayer.Name then
rank.Value = "LTGEN"
end
end
for i=1, #GEN do
if GEN[i] == game.Players.LocalPlayer.Name then
rank.Value = "GEN"
end
end
for i=1, #FM do
if FM[i] == game.Players.LocalPlayer.Name then
rank.Value = "FM"
end
end
rank.Parent = stats
reg.Parent = stats
end)
The problem is: It works flawlessly in studio, but not in game :/ Any help? Am I doing something wrong?

3 comments
Does not work. :/ I've tried putting this Script in Server storage and script service but this one doesn't even work in studio.
have you turned on studio access API on configure game/place
I have edited the script. It should work now.