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

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

Asked by 4 years ago
Edited 4 years ago

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

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? dadysherwin2 155 — 4y

1 answer

Log in to vote
0
Answered by
karbis 50
4 years ago

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
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! ZeroNoey 19 — 4y
Ad

Answer this question