Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My script only runs once then it stops firing the function. Any help?

Asked by 9 years ago

So I tested my script out and it only ran once and then the next person who joined it didn't run. I suspect its an error, but I can not find it no matter how many times i look through it. Maybe one of you can? Here is the script:

for i = 1, leader.MaxPlayers.Value do
local x = Instance.new("TextLabel")
x.Parent = leader.Players
x.Name = "Player" .. i .. "L"
x.Size = UDim2.new(0, 120, 0, 10)
x.FontSize = "Size14"
x.TextColor3 = Color3.new(color)
x.BackgroundTransparency = 1
x.BorderSizePixel = 0
x.Position = UDim2.new(0, 50, 0, 50) + UDim2.new(0, 0, 0, 20*i)
x.Visible = false
-------------------- LABELS MADE ------------------------------
local w = Instance.new("StringValue")
w.Parent = leader.Players
w.Name = "Player" .. i 
table.insert(playerlist, x)
table.insert(playervalue, w)    
end
game.Players.PlayerAdded:connect(function(plr)
for i, v in pairs(playervalue) do
    if adding == false then
    if v.Value == "" then
        v.Value = plr.Name
        print("Player Added")
        adding = true
    end
    end
end
adding = false
if Stats == true then
        game.StarterGui.Leaderboard.Stats2.Value = true
    local starterstats = Instance.new("Model")
    if StatsName ~= "" then
    starterstats.Name = StatsName
    starterstats.Parent = plr
    end
    if Stat1 ~= "" then
    local firststat = Instance.new(Stat1Type)
    firststat.Parent = starterstats

    firststat.Value = Stat1Value
    firststat.Name = Stat1
    end
    if Stat2 ~= "" then
        local secondstat = Instance.new(Stat2Type)
            secondstat.Parent = starterstats
        secondstat.Value = Stat2Value
        secondstat.Name = Stat2
    end
    if Stat3 ~= "" then
    local thirdstat = Instance.new(Stat3Type)
    thirdstat.Parent = starterstats
    thirdstat.Value = Stat3Value
    thirdstat.Name = Stat3
    end

game.Players.PlayerAdded:connect(function(plr)
for i, v in pairs(playervalue) do
    if adding == false then
    if v.Value == "" then
        v.Value = plr.Name
        print("Player Added")
        adding = true
    end
    end
end
adding = false
if Stats == true then
        game.StarterGui.Leaderboard.Stats2.Value = true
    local starterstats = Instance.new("Model")
    if StatsName ~= "" then
    starterstats.Name = StatsName
    starterstats.Parent = plr
    end
    if Stat1 ~= "" then
    local firststat = Instance.new(Stat1Type)
    firststat.Parent = starterstats

    firststat.Value = Stat1Value
    firststat.Name = Stat1
    end
    if Stat2 ~= "" then
        local secondstat = Instance.new(Stat2Type)
            secondstat.Parent = starterstats
        secondstat.Value = Stat2Value
        secondstat.Name = Stat2
    end
    if Stat3 ~= "" then
    local thirdstat = Instance.new(Stat3Type)
    thirdstat.Parent = starterstats
    thirdstat.Value = Stat3Value
    thirdstat.Name = Stat3
    end
0
While testing it in your game, go to the menu>help>developers console, and check for script errors . If you see any, edit your post to add them. SanityMan 239 — 9y
0
Give us more information, what is it supposed to do? What is it doing instead? Lacryma 548 — 9y
0
@ Dueling, Its supposed to make a value the players name when it enters, and its only making one value the players name then the next player to come it doesn't change the next value thats empty. deputychicken 226 — 9y

1 answer

Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
9 years ago

You're using :connect(function() wich means it doesnt stop on END, it stops at END) replace the last end with end) (didnt read full trough, but i didnt see any end) and you're supposed to put them after :connect(function() )

Ad

Answer this question