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

How do i stop this from duplicating?

Asked by 10 years ago

I'm working on a report system and whenever one of my admins go to check reports, it duplicates the textbutton when it shouldn't. I have 2 of the same script in the same parent/frame but one Parents the PlayerGui and the other parents the StarterGUI. Please help me

game.Lighting.Reports.ChildAdded:connect(function (child)
    wait(3)
    local reports = game.Lighting.Reports
    local player = child.Player.Value

    local newbutton = Instance.new("TextButton")
    local prev = game.StarterGui.ReportGUI.CheckReports.PrevButton
    local button = game.StarterGui.ReportGUI.CheckReports["TextButton"..prev.Value]

    if child then
        newbutton.BackgroundColor3 = Color3.new(100/255, 100/255, 100/255)
        newbutton.BackgroundTransparency = 0.3 
        newbutton.Position = button.Position + UDim2.new(0,0,0,30)
        newbutton.Name = "TextButton"..prev.Value + 1
        newbutton.Size = UDim2.new(0, 430, 0, 23)
        newbutton.Font = "SourceSansBold"
        newbutton.FontSize = Enum.FontSize.Size18
        newbutton.Text = player
        newbutton.TextColor3 = Color3.new(0, 0, 0)
        newbutton.Parent = game.StarterGui.ReportGUI.CheckReports

        local lightingscript = game.Lighting.ScriptsForReport

        lightingscript.ButtonPress:Clone().Parent = game.StarterGui.ReportGUI.CheckReports["TextButton"..prev.Value + 1]

        prev.Value = prev.Value + 1
    end
end)

Answer this question