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
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)
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
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)
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)