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

My Script is breaking?

Asked by 10 years ago

I do this but it keeps breaking

Main Script:

function UpdateOldLabels(Parent)
    for i,v in pairs(Parent:GetChildren()) do
        if v.Name:sub(1,4):lower() == "line" then
            local LineNumber = v.Name:sub(5)
            if LineNumber == "12" then
                v:Destroy()
            else
                v.Name = "line"..tostring(tonumber(LineNumber) + 1)
                v.Position = v.Position - UDim2.new(0,0,0,15)
            end
        end
    end
end

game:GetService("Players").PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        for _,v in ipairs(game:GetService("Players"):GetChildren()) do
            UpdateOldLabels(v:WaitForChild("PlayerGui").ChatGui.Frame)
            newchatline = Instance.new("TextLabel",v:WaitForChild("PlayerGui").ChatGui.Frame)
            newchatline.Text = player.Name=='EmperorF' and ("[SMITE FOUNDER] "..player.Name.. ": " ..msg) or (player.Name.. ": " ..msg)
            newchatline.Size = UDim2.new(1,0,0,15)
            newchatline.Position = UDim2.new(0,0,1,-15)
            newchatline.Font = "SourceSansBold"
            newchatline.TextColor3 = player.Name=="EmperorF" and BrickColor.new("Bright red").Color or player.TeamColor.Color
            newchatline.TextStrokeTransparency = 0
            newchatline.BackgroundTransparency = 1
            newchatline.BorderSizePixel = 0
            newchatline.FontSize = "Size14"
            newchatline.TextXAlignment = "Left"
            newchatline.TextYAlignment = "Top"
            newchatline.ClipsDescendants = true
            newchatline.Name = "line1"
        end
        UpdateOldLabels(game:GetService("StarterGui").ChatGui.Frame)
        newchatline:Clone().Parent = game:GetService("StarterGui").ChatGui.Frame
    end)
end)

What I need to add:

newchatline.Text = player.Name=='EmperorF' and ("[SMITE FOUNDER] "..player.Name.. ": " ..msg) or (player.Name.. ": " ..msg)
newchatline.Text = player.Name=='thekingsband' and ("[SMITE CO-FOUNDER] "..player.Name.. ": " ..msg) or (player.Name.. ": " ..msg)
newchatline.Text = player.Name=='tyopido' and ("[SMITE HEAD DEVELOPER] "..player.Name.. ": " ..msg) or (player.Name.. ": " ..msg)
newchatline.Text = player.Name=='randomman1234' and ("[SMITE DEVELOPER] "..player.Name.. ": " ..msg) or (player.Name.. ": " ..msg)

In all:

function UpdateOldLabels(Parent)
    for i,v in pairs(Parent:GetChildren()) do
        if v.Name:sub(1,4):lower() == "line" then
            local LineNumber = v.Name:sub(5)
            if LineNumber == "12" then
                v:Destroy()
            else
                v.Name = "line"..tostring(tonumber(LineNumber) + 1)
                v.Position = v.Position - UDim2.new(0,0,0,15)
            end
        end
    end
end

game:GetService("Players").PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        for _,v in ipairs(game:GetService("Players"):GetChildren()) do
            UpdateOldLabels(v:WaitForChild("PlayerGui").ChatGui.Frame)
            newchatline = Instance.new("TextLabel",v:WaitForChild("PlayerGui").ChatGui.Frame)
            newchatline.Text = player.Name=='EmperorF' and ("[SMITE FOUNDER] "..player.Name.. ": " ..msg) or (player.Name.. ": " ..msg)
newchatline.Text = player.Name=='thekingsband' and ("[SMITE CO-FOUNDER] "..player.Name.. ": " ..msg) or (player.Name.. ": " ..msg)
newchatline.Text = player.Name=='tyopido' and ("[SMITE HEAD DEVELOPER] "..player.Name.. ": " ..msg) or (player.Name.. ": " ..msg)
newchatline.Text = player.Name=='randomman1234' and ("[SMITE DEVELOPER] "..player.Name.. ": " ..msg) or (player.Name.. ": " ..msg)
            newchatline.Size = UDim2.new(1,0,0,15)
            newchatline.Position = UDim2.new(0,0,1,-15)
            newchatline.Font = "SourceSansBold"
            newchatline.TextColor3 = player.Name=="EmperorF" and BrickColor.new("Bright red").Color or player.TeamColor.Color
            newchatline.TextStrokeTransparency = 0
            newchatline.BackgroundTransparency = 1
            newchatline.BorderSizePixel = 0
            newchatline.FontSize = "Size14"
            newchatline.TextXAlignment = "Left"
            newchatline.TextYAlignment = "Top"
            newchatline.ClipsDescendants = true
            newchatline.Name = "line1"
        end
        UpdateOldLabels(game:GetService("StarterGui").ChatGui.Frame)
        newchatline:Clone().Parent = game:GetService("StarterGui").ChatGui.Frame
    end)
end)

But it wont work someone help?

1 answer

Log in to vote
0
Answered by
3rdblox 30
10 years ago

Posting large blocks of code isn't usually a good idea here. Try to pin the issue down then come back, shorter posts get replies faster.

Ad

Answer this question