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:
01 | function UpdateOldLabels(Parent) |
02 | for i,v in pairs (Parent:GetChildren()) do |
03 | if v.Name:sub( 1 , 4 ):lower() = = "line" then |
04 | local LineNumber = v.Name:sub( 5 ) |
05 | if LineNumber = = 12 then |
06 | v:Destroy() |
07 | else |
08 | v.Name = "line" .. tostring ( tonumber (LineNumber) + 1 ) |
09 | v.Position = v.Position - UDim 2. new( 0 , 0 , 0.035 , 0 ) |
10 | end |
11 | end |
12 | end |
13 | end |
14 |
15 |
LocalScript:
1 | script.Parent.InputEnded:connect( function () |
2 | game.Workspace.Events.Other.Chat:FireServer(game.Players.LocalPlayer, script.Parent.Text) |
3 | script.Parent.Text = [[Click here or press the "/" key to chat.]] |
4 |
5 | end ) |
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
1 | RemoteEvent.OnServerInvoke:Connect( function (player, message) |
2 | print (player.Name .. " says: " .. message) |
3 | end ) |
Client
1 | RemoteEvent:FireServer( "Message" ) |