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

How can I create a variable that uses a number inputted into a textbox?

I am trying to make a rope constraint change length using a gui that appears when the tool is held in the lower right hand corner of the screen. I've already made the gui appear and disappear, but I need to figure out how to make the length of the rope change when the player types a number into the textbox. To do this, I need to know how to detect the number and use it as a variable that will serve to change the length of the rope. Any help is appreciated, thanks!

repeat wait() until script.Parent.Parent.Name ~= "Backpack"
local char = script.Parent.Parent
local player = game.Players:GetPlayerFromCharacter(char)

while wait() do
	script.Parent.Money.RopeConstraint.Length = player.PlayerGui.BaitLengthGui.Frame.Textbox.Text -- This is where I am having issues
end

1 comment

0

Maybe you could make the text equal into a number value in the player maybe and then the number value would become the rope length?

1 answer

✓ Accepted answer

try this

repeat wait() until script.Parent.Parent.Name ~= "Backpack"
local char = script.Parent.Parent
local player = game.Players:GetPlayerFromCharacter(char)
	 
while wait() do
if tonumber(player.PlayerGui.BaitLengthGui.Frame.TextBox.Text) then
	    script.Parent.Money.RopeConstraint.Length = tonumber(player.PlayerGui.BaitLengthGui.Frame.Textbox.Text)
end
end

1 comment

0

When I ran the game, the rope changed to the length inputted into the text box by default, but I am not able to change the length of the rope by changing the number in the text box. Still, this answers my main question. Thanks!

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