hello! Im trying to make a script that links up a textbox's text and the health of a humanoid. the model with the humanoid has a part in it that has the textbox. im trying to make it so that if the textbox says "90" the humanoid's health will be set to 90. ive tried just about everything that I know of. It shows no errors or anything in the output (but the "Testing" shows up in the output). so yeah, please help. thank you in advance! ^^
heres the code i used, its pretty simple. I just dont know why it isnt working :
while true do wait(.15) print("Testing") if script.Parent.Text == "90" then script.Parent.Parent.Parent.Parent.Humanoid.Health = 90 end end
so yeah..
Well, I Think You Are Making A Gui Where it shows your health. I think this will help?
t's Good to put a print in an if statement.
script.Parent.Text.InputChanged:Connect(function(text) script.Parent.Parent.Parent.Parent.Humanoid.Health = text print(text) end) ~~~~~~~~~~~~~~~~~
This is easier.
script.Parent.Changed:Connect(function() print("Testing") script.Parent.Parent.Parent.Parent.Humanoid.Health = tonumber(script.Parent.Text) end)
And make sure you didn't change the text by localscript since it will be visible for one device. Make sure this is a script too.
But if you are only going for 90 then
script.Parent.Changed:Connect(function() print("Testing") if script.Parent.Text = '90' then script.Parent.Parent.Parent.Parent.Humanoid.Health = tonumber(script.Parent.Text) end end)
Make sure the text when changed is exactly 90 or exactly a number.