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

Chat script cannont concantenate local 'msg'?

Asked by
H4X0MSYT 536 Moderation Voter
7 years ago
Edited 7 years ago

Basically, I made a chat. On the main script, an error occurs on line 20, "attempt to concantenate local 'msg' a nil value" I have no idea whats wrong with it. Nor do I know what this means...

ServerScript:

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.035, 0)
            end
        end
    end 
end




function NewLine(parent, plr, msg)
    local New = Instance.new("TextLabel", parent)
    New.Text = plr.Name .. ": " .. msg
    New.Size = UDim2.new(0.35, 0, 0.026, 0)
    New.Position = UDim2.new(0, 0, 0.315, 0)
    New.BorderSizePixel = 0
    New.BackgroundTransparency = 1
    New.TextColor3 = Color3.fromRGB(255, 255, 255)
    New.TextStrokeTransparency = 1
    New.FontSize = "Size10"
    New.TextXAlignment = "Left"
    New.TextYAlignment = "Top"
    New.Name = "Line1"
    New.ClipsDescendants = true
end
workspace.Events.Other.Chat.OnServerEvent:connect(function(plr, msg)
        for _,v in ipairs(game:GetService("Players"):GetChildren()) do
            NewLine(v:WaitForChild("PlayerGui").Chat.Container.ChatLines, plr, msg)
            UpdateOldLabels(v:WaitForChild("PlayerGui").Chat.Container.ChatLines)
        end
end)

LocalScript:

script.Parent.InputEnded:connect(function()
    game.Workspace.Events.Other.Chat:FireServer(game.Players.LocalPlayer, script.Parent.Text)
    script.Parent.Text = [[Click here or press the "/" key to chat.]]

end)
0
There's no end in the third or first code; is this not the full script, if not, could you please provide it? :) And are you using a Local or Server script? TheeDeathCaster 2368 — 7y
0
This legit is on a video. From a year ago too. SGYTMinersHaven -16 — 6y
0
First of all, you have -5 points. You cannot criticize me. This was a year ago. There is no ******* need to reply. H4X0MSYT 536 — 6y

1 answer

Log in to vote
1
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

The problem is that OnServerEvent automatically provides the player who's client fired the event, so you don't need to provide it.

Signal OnServerEvent (
??? Player player,
??? Variant... arguments
)

When you given the arguments player, message to FireServer, the function connected to OnServerEvent receives the arguments player, player, message. To fix this, try passing the text in as the only argument to FireServer.

Example:
Server

RemoteEvent.OnServerInvoke:Connect(function(player, message)
    print(player.Name .. " says: " .. message)
end)

Client

RemoteEvent:FireServer("Message")
Ad

Answer this question