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

How can I make a TextLabel's Text the value of an IntValue?

I'm making a GUI that shows the health of a tree being cut down.

s=game.StarterGui.Status.TextLabel
h=script.Parent.Parent.hit

function onTouched(hit)
	s.Text=h.Value
end

script.Parent.Touched:connect(onTouched)
--hit is the name of an intValue
--the s variable leads to a text label

for some reason, it doesn't work when I touch the part, what's going on?

4 comments

0

C'mon please help

0

s.Text = tostring(h.Value)

0

k thx

0

still doesn't work :/

2 answers

That's because you are changing the version in StarterGui to it. If you did this and then reset, it would change for you. You're going to have to use something like this:

players = game.Players:GetChildren()
h = script.Parent.Parent.hit
function onTouched(hit)
	for _,v in pairs(players) do
		players.PlayerGui.Status.TextLabel.Text = h.Value
	end
	game.StarterGui.Status.TextLabel.Text = h.Value
end

script.Parent.Touched:connect(onTouched)

I haven't tested the code above, but it should work.

4 comments

0

did you miss a do? after the for _,v in pairs?

0

Ah, yes, i'm not a pro scripter but I like helping, thanks for telling me

0

still doesn't seem to work :/

0

i might just try a different method, thats a lot longer

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