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

TextBox.Text is always empty?

Asked by
DogeIXX 172
4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

0
Thanks, works great! DogeIXX 172 — 4y
0
But I do have one question now, can I put the Value in a :FireServer()? Because that doesnt really work. DogeIXX 172 — 4y
0
I dont believe you can put the value in a fire server. RobloxGameingStudios 145 — 4y
Ad

Answer this question