Client Script
local Player = game.Players.LocalPlayer local Message = script.Parent.Text game.ReplicatedStorage.SendServer:FireServer(Player, Message)
Server Script
game.ReplicatedStorage.SendServer.OnServerEvent:connect(function(player,msg) if not LengthCheck(msg) then function LengthCheck(Message) if string.len(Message) > 100 then return false else return true end end
Error Output-
bad argument #1 to 'len' (string expected, got Object)
When firing a server event, the player (client) who sent the request is already sent to the function. This means our server script is actually getting
function(player, player, message)
You just need to remove 'Player' from :FireServer()
Your error is that you used the:FireServer
method with the Player argument when :FireServer
already sends that information as default. This is why string.len
spits out an error saying it got an Object instead of a string.
Client
local Player = game.Players.LocalPlayer local Message = script.Parent.Text game.ReplicatedStorage.SendServer:FireServer(Message) -- Only needs the message argument