The script is part of a gui to buy something called bonds. I'm having a problem with (input which is script.Parent.Text) and (output which is script.Parent.Parent.HowManyResult.Text). when I put in a number in the script.Parent.Text, the number goes to script.Parent.Parent.InputVal.Value which is multiplied by bondprice to get the cost of however many bonds you want. However many bonds you want are only limited by the maximum amount of bonds which makes the maximum price. The bondprice.Value is 7. the output is supposed to be the bondprice.Value times the script.Parent.Parent.InputVal.Value and the problem is that the output isn't the input value * 7. If I wanted 1 bond the output would be 0 and it's supposed to be 7, that's the problem. Can someone help me, thank you. The script is below.
--// Edited for code block. In the future please be sure to enclose your code between two lines of tildes (~), which can be inserted by clicking the blue button under the title of the question editor. local theinput = script.Parent.Parent.InputVal local player = game.Players.LocalPlayer script.Parent.Changed:connect(function() local bondprice = game.Lighting.Bank.Price.BondPrice local maximumshares = math.floor(player.PlayerMoney.Value/bondprice.Value) local maximumprice = math.floor(maximumshares*bondprice.Value) local n = tonumber(script.Parent.Text) if (not n) then return end if theinput.Value > maximumshares then script.Parent.Parent.HowManyResult.Text = "$" .. maximumprice elseif theinput.Value < maximumshares then script.Parent.Parent.HowManyResult.Text = "$" .. theinput.Value * bondprice.Value end end) while wait(0.01) do theinput.Value = script.Parent.Text end
I believe your code is getting stuck in your while loop
local theinput = script.Parent.Parent.InputVal local player = game.Players.LocalPlayer function changed() --I changed the code you had into a function that we will call when the script.Parent changes local bondprice = game.Lighting.Bank.Price.BondPrice local maximumshares = math.floor(player.PlayerMoney.Value/bondprice.Value) local maximumprice = math.floor(maximumshares*bondprice.Value) local n = tonumber(script.Parent.Text) if (not n) then return end if theinput.Value > maximumshares then script.Parent.Parent.HowManyResult.Text = "$" .. maximumprice elseif theinput.Value < maximumshares then script.Parent.Parent.HowManyResult.Text = "$" .. theinput.Value * bondprice.Value end end game:GetService("RunService").RenderStepped:connect(funtion() -- Since this is in a localscript we can use RenderStepped from RunService check and update every frame that is rendered. theinput.Value = script.Parent.Text changed(); -- We are calling the function here to see if it changes. end)
I hope this helped. If it did please accept this as the answer. If it didn't feel free to comment so I can try to help and figure out why it isn't working.