Data Sending "Client to Server" Problem

I want to send a property’s data to the server that is only in the client, for example:

local TextProperty = TextBox.Text

with RemoteEvents but that property in the server is nil, I want to send to the server the text, for example “123”, but it gets the TextBox.Text instruction instead of “123” then the server gets nil because that text does not exist in the server.

I don’t know how to fix this since I am a begginer :disappointed_relieved:

Can I see more of the script please.

local Button = script.Parent
local RS = game:GetService("ReplicatedStorage")
local RemoteEvent = RS:WaitForChild("SendText")
local TextBox = Button.Parent:WaitForChild("TextBox")

Button.MouseButton1Click:Connect(function(player)

     local Text = TextBox.Text
     RemoteEvent:FireServer(player,Text)

end)

Ok you do not need to send the player argument it already has that do this for e.g:

remoteEvent:FireServer(textLabel) -- //Do text label "Text" is a build in function thing it will error as well

--Other Script
remoteEvent.OnServerEvent:Connect(function(player,textLabel)
    -- //Your code..
end)
1 Like

You only call the player parameter on a local script for :FireClient

Oh and do this:

local player = game.Players.LocalPlayer
Button.MouseButton1Click:Connect(function()
    -- //Your code..
end)

I won’t need :FireClient since I use the server to replicate to everyone the data that one player is sending, like an Audio ID (I’m making a boombox for testing)

Thanks for “cleaning” the code but the server gets nil yet :slightly_frowning_face:

FireClient can only be called from a server script…

This should work.

local Button = script.Parent
local RS = game:GetService("ReplicatedStorage")
local RemoteEvent = RS:WaitForChild("SendText")
local TextBox = Button.Parent:WaitForChild("TextBox")

Button.MouseButton1Click:Connect(function(player)
     RemoteEvent:FireServer(TextBox.Text)
end)

Server Script:

local Event = game.ReplicatedStorage.SendText
Event.OnServerEvent(function(Player,Text)
   print(Text)
end)
1 Like

OutputError

I never got that error. What does it mean? :thinking:

Can you screenshot everything in your replicatedstorage and send it please.

Try this

local Button = script.Parent
local RS = game:GetService("ReplicatedStorage")
local RemoteEvent = RS:WaitForChild("SendText")
local TextBox = Button.Parent:WaitForChild("TextBox")

Button.MouseButton1Click:Connect(function()
     RemoteEvent:FireServer(TextBox.Text)
end)

Server Script:

local Event = game.ReplicatedStorage.SendText
Event.OnServerEvent:Connect(function(Player,Text)
   print(Text)
end)

@Mr_Qaxt

2 Likes

you didnt connect the evnt to a function thats why it error

1 Like

Good pickup. @Mr_Qaxt modify my example respectfully.

1 Like

oh and also you put a player parameter in the mousebutton1click which you dont have to

Because You cannot use :FireServer on a serverscript only localscript

Thanks @Creeperman16487 and @IEnforce_Lawz. The server now gets the text instead of nil :grinning:

oh great good to hear that!!(i need 30 letters arghh)