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

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

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

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)


2 comments

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)

0

Oh.

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.

3 comments

0

Oh, and make sure you reference the obj right.

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.

0

.-., this only makes it worse to read as well as not helpful, OP's solution was better.

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