I cant get text box text to another gui

I want to get the number and string of a text box, inputted by a player.
I can explain in the video:
robloxapp-20220806-2117348.wmv (1.7 MB)
So first we set a value to true, you dont need to mind that.
Then i start a script, by selling the item for a specified amount, as you can see.
Then im inputting an string into the text box, i have tried converting into string and number, but failed. It showed me once "Your item sold for !"
So if it should work, then it should say: “Your item sold for (TextBox String) !”

This is the serverscript that handles the remote event:

repStorage.sellEvents.sellToy.OnServerEvent:Connect(function(Client)
	local strConvert = Client.PlayerGui.MainUI.SellNow.Frame.ScrollingFrame.toySell.TextBox.Text
	local c = game.ServerStorage.SoldGUI:Clone()
	c.Parent = Client.PlayerGui
	c["Sold!"].forPrice.Text = ("You sold your item for "..strConvert.."!") -- Here its not showing it.
	wait(5)
	c:Destroy()
end)

And this is the local script under the text button:

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.sellEvents.sellToy:FireServer(game.Players.LocalPlayer, script.Parent.TextBox.Text)
end)

If its very confusing i can tell in an simple way:
I wanna get the number and string of a text box, the player inputs a string that is a number and it converts into number, but also a string, that means i want to create a variable for the number and i want to show that number by adding a text in the Sold GUI so the text says for how much i sold it, basically just like adding a text box input, and showing it in another text but just with creating a variable, that converts that string into the number that the player inputted into the textbox
Hope you can help thanks!

You don’t need to send the LocalPlayer in the FireServer event as it’s sent automatically so just use

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.sellEvents.sellToy:FireServer(script.Parent.TextBox.Text)
end)

But then, on the server side you haven’t set a variable to capture the TextBox.Text you are sending over:

repStorage.sellEvents.sellToy.OnServerEvent:Connect(function(Client)

should be:

repStorage.sellEvents.sellToy.OnServerEvent:Connect(function(Client, SentText)

You can then use SentText as your captured string

1 Like

Thank you so much! It works!

1 Like