Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

RemoteEvent: How do I send a .Text as an argument ?

Asked by 6 years ago
Edited 6 years ago

hai! When I send the following to a RemoteEvent, I get an error where it says a String was expected for argument 2. How can I send something like this?

local player = game.Players.LocalPlayer
local player2 = script.Parent.Parent.user.Text
game.ReplicatedStorage.aaa:FireServer(player, player2)

1 answer

Log in to vote
2
Answered by
DanzLua 2879 Moderation Voter Community Moderator
6 years ago

The function :FireServer() does not require a player argument unlike the :FireClient() function which does, therefore the corresponding event .OnServerEvent does return a player in the first argument, after this would be any thing you sent over as well.

The problem with your script is because this function doesnt require a player argument you are sending two things to the server, the player and example. The most likely cause of your problem is that on the receiving end of this you are assigning the first returned value expecting it to the the string but it is actually the player, then the next value would be that string.

tl;dr

local example = script.Parent.Parent.user.Text
game.ReplicatedStorage.aaa:FireServer(example) --doesn't need player
0
thank you! ;p ShallowGrouchyAdrian 3 — 6y
0
@ShallowGrouchyAdrian accept answer? DanzLua 2879 — 6y
Ad

Answer this question