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

I asked this in a different question but havent got any answers?? :(

Asked by
kuru226 13
2 years ago
Edited 2 years ago

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..

2 answers

Log in to vote
0
Answered by 2 years ago

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) ~~~~~~~~~~~~~~~~~

0
its a group in workspace, it has a humanoid that is supposed to have the same health as the player. and show that on the textbox. so when the player's health = 90, then the textbox says "90" and then the humanoid's health goes to 90. (this sounds so stupid saying this outloud haha) kuru226 13 — 2y
0
Oh. Brioche_Noodle 45 — 2y
Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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.

0
Oh, and make sure you reference the obj right. AProgrammR 398 — 2y
0
can you add me on discord please? none of the things are really working and thats the only thing i can think of to send a screenshot of whats going on. kuru226 13 — 2y
0
.-., this only makes it worse to read as well as not helpful, OP's solution was better. greatneil80 2647 — 2y

Answer this question