String expected, got Object in EventMgr script on Line 3 when trying to run event in LocalScript

  1. What do you want to achieve? Keep it simple and clear!
    I am trying to let a player type in a username in a TextBox, and have a
    RemoteEvent that makes that player go on the bright red “Nominees” team.
  2. What is the issue? Include screenshots/videos if possible!
ServerScriptService.EventMgr:3: bad argument #2 to '?' (string expected, got Object)
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Using tostring like this:
local nomineeTwo = tostring(script.Parent.Parent.NomineeBox.Text)
game.ReplicatedStorage.Events.Nominate:FireServer(nomineeTwo)

and it gives me the same error.
Trying to use print to do the same thing in the Command Bar: it was successful but applying the method to the script gave the same error.

Please could you provide an example of the code within ServerScriptService.EventMgr as this is where your error is coming from.

1 Like

Oh, sorry about that, I forgot.

events.Nominate.OnServerEvent:Connect(function(playerChosen)
	game.Players[playerChosen].Team = game.Teams.Nominees
end)

You are getting this error because you are passing through a string argument to FireServer, and in the event you have declared the default player argument for the OnServerEvent connection as playerChosen (this is the player that FireServer was sent from on the client)

You are using FireServer correct, but the event should look like this:

events.Nominate.OnServerEvent:Connect(function(playerFrom, playerChosen)
	game.Players[playerChosen].Team = game.Teams.Nominees
end)
3 Likes