I've been trying to make a chat and I've been running into this problem where it says "attempt to concatenate local 'message' (a userdata value)" and I've fixed it before but then I broke it and forgot how I fixed it, yeah, I broke it while trying to fix another problem so I came here after trying again and again to no avail, I didn't get it to work again. I've got 3 scripts, a local script, a server script, and a module script. Don't ask why I renamed the scripts to weird names, I just thought they sounded fitting. Anyways here they are. I posted them in the order they are activated.
Local Script:
focusButton = "Slash" gui=script.Parent.Parent --[[TouchScreenEnum = {Enum.Platform.WiiU,Enum.Platform.Android,Enum.Platform.AndroidTV,Enum.Platform.Chromecast, Enum.Platform.IOS,Enum.Platform.Ouya} consoleEnum = {Enum.Platform.XBox360,Enum.Platform.XBoxOne} for i,v in ipairs(TouchScreenEnum, consoleEnum) do if game.Players.LocalPlayer.OsPlatform==v then script.Parent.NonPCOS:InvokeServer(game.Players.LocalPlayer.OsPlatform) break end end]] script.Parent.Parent.ChatBox.FocusLost:connect(function(enterPressed) if enterPressed then script.Parent.SendMessage:InvokeServer(game.Players.LocalPlayer,gui.ChatBox.Text) end end) script.Parent.Parent.ChatBox.ImageButton.MouseButton1Click:Connect(function() script.Parent.SendMessage:InvokeServer(game.Players.LocalPlayer,gui.ChatBox.Text) end) game:GetService("UserInputService").InputBegan:Connect(function(IO,GPE) if Enum.KeyCode[focusButton]==IO.KeyCode and not gui.ChatBox:IsFocused() then script.Parent.Parent.ChatBox:CaptureFocus() end end)
Server Script:
eventProcessor = require(script.Parent.EventProcessor) ts = game:GetService("TextService") --[[script.NonPCOS.OnServerInvoke:Connect(function(OS) if OS==Enum.Platform.XBox360 or OS==Enum.Platform.XBoxOne then script.Parent.ChatBox.PlaceholderText="Press select and press A here to chat." else script.Parent.ChatBox.PlaceholderText="Tap here to chat." end end)]] function script.SendMessage.OnServerInvoke(plr,text) script.Parent.ChatBox.Text="" local success,errorMessage = pcall(function() filteredText = ts:FilterStringAsync(text,plr.UserId) end) if success then eventProcessor.AddMessage(plr,filteredText) else eventProcessor.RecieveMessage("SYSTEM","Sorry, "..plr.Name .." but there has been an error and your text has not been sent, please resend your message. Error: "..errorMessage .." Only you can see this message") end end
Module Script:
local module = {} ts = game:GetService("TextService") sStorage = game:GetService("ServerStorage") messages = 0 function module.AddMessage(plr,message) if #script.Parent.ChatFrame:GetChildren()>=8 then script.Parent.ChatFrame.CanvasSize.Y.Offset=script.Parent.ChatFrame.CanvasSize.Y.Offset+25 end for i,v in ipairs(game.Players:GetChildren()) do local chat = sStorage.playerName:Clone() chat.Name=plr.Name chat.message="["..plr.Name.."]: "..message chat.Parent=v.PlayerGui.Chat.ChatFrame chat.Position.Y.Offset=25*#v.PlayerGui.Chat.ChatFrame:GetChildren() messages=#script.Parent.ChatFrame:GetChildren() end end function module.RecieveMessage(plr,message) if #script.Parent.ChatFrame:GetChildren()>=8 then script.Parent.ChatFrame.CanvasSize.Y.Offset=script.Parent.ChatFrame.CanvasSize.Y.Offset+25 end local chat = sStorage.playerName:Clone() chat.Name=plr.Name chat.message="["..plr.Name.."]: "..message chat.Parent=script.Parent.ChatFrame chat.Position.Y.Offset=25*#script.Parent.ChatFrame:GetChildren() messages=#script.Parent.ChatFrame:GetChildren() end return module
Any help? I probably will forget about this in a day, so please be quick if possible, I don't need a script, just some advice or ideas, thanks in advance!
I can't read some of the lines because they were too long and got cut off, but I think you are concatenating the player object instead of its name at line 18 in the server script.