Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

TextBox.Text is always empty?

Hey, another question for today.

I am trying to get the text of a textbox.

As test, I try to print the text that was put in.

But always, nothing gets printed, just an empty space.

I dont know how to fix that, since I dont find any other Option that gives the input of the TextBox.

Thats the script.

local player = script.Parent.Parent.PlayerName.Text
local coins = script.Parent.Parent.CoinsAmount.Text
local CoinChange = game.ReplicatedStorage.CoinChange


script.Parent.MouseButton1Click:Connect(function()
    workspace.CoinChange.Coins.Value = coins
    workspace.CoinChange.Player.Value = player
print(workspace.CoinChange.Coins.Value)
print(coins)
	CoinChange:FireServer(coins, player)
end)

1 answer

✓ Accepted answer

Hmm.. where is this script located, if it's in a button im assuming u want it to print the text value? Also make sure it's a local script.

script.Parent.MouseButton1Click:connect(function()
	print(script.Parent.Parent.Coins.Text) -- points to a textlabel to grab the text data from and print it when u click
end)

This is what I usually do, and your script may work, it's just not a local script, I cant help your current script because i'm confused what the variables are and what they are pointing to.

Hm.. Try This: I'm assuming u want it to change the text to the coin change when clicked?

local player = game.Players.LocalPlayer -- this line was changed. Now connects to player
local coins = script.Parent.Parent.CoinsAmount -- connects to the text
local CoinChange = game.ReplicatedStorage.CoinChange -- remote event


script.Parent.MouseButton1Click:Connect(function()
    coins.Text = player.leaderstats.Coins.Value
    CoinChange:FireServer()
end)

Please read below for the errors i found:

Your error is very simple to point out, 'CoinChange' is not a part of workspace, it's in replicated storage, but u put workspace.CoinChange, which may result in a not written error. also, how can text be a part of a remote event? Also, a value cant be part of a remote event or text value at the same time! Also, player cannot connect like that.

3 comments

0

Thanks, works great!

0

But I do have one question now, can I put the Value in a :FireServer()? Because that doesnt really work.

0

I dont believe you can put the value in a fire server.

This discussion is preserved as it was. New answers, comments, and votes are closed.