Answered by
6 years ago Edited 6 years ago
Well one problem I could find right away is that the Client-Server communication actually gives 3 arguments and not the two you specified.
All client-server communications that are utilized with the Event object provide the player itself.
So you can remove the "PlrName" argument and just utilize the player's name, here's a rework:
Edit: Kirot is right, I did a big booboo on this one rip. As he mentions in a comment, we should've done "OnServerEvent" instead.
Send Button:
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | local text = script.Parent.Parent.TextBox.Text |
3 | game.ReplicatedStorage.Message:FireServer(text) |
Label: (Ignore this one, it was a failure RIP)
1 | game.ReplicatedStorage.Message.OnClientEvent:Connect( function (player, text) |
2 | local PlrName = player.Name |
3 | script.Parent.Text = PlrName.. ": " ..text |
Rewrite of Label (This one doesn't work either rip):
1 | game.ReplicatedStorage.Message.OnServerEvent:Connect( function (player, text) |
2 | local PlrName = player.Name |
3 | script.Parent.Text = PlrName.. ": " ..text |
As for the text issue, it should've just returned the player's name. Are you sure the Send Button is the secondary or first parent of the script?
What I mean is:
Secondary Parent:
script --> 1st Parent --> SendButton (This is how it's working right now)
First Parent:
script --> SendButton (How I think it'll need to work like)