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

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

Asked by 9 years ago

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?

0
C'mon please help fattyfateric1 0 — 9y
0
s.Text = tostring(h.Value) funyun 958 — 9y
0
k thx fattyfateric1 0 — 9y
0
still doesn't work :/ fattyfateric1 0 — 9y

2 answers

Log in to vote
0
Answered by
shayner32 478 Trusted Moderation Voter
9 years ago

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.

0
did you miss a do? after the for _,v in pairs? fattyfateric1 0 — 9y
0
Ah, yes, i'm not a pro scripter but I like helping, thanks for telling me shayner32 478 — 9y
0
still doesn't seem to work :/ fattyfateric1 0 — 9y
0
i might just try a different method, thats a lot longer fattyfateric1 0 — 9y
Ad
Log in to vote
0
Answered by
iNicklas 215 Moderation Voter
9 years ago

Where is the IntValue located?

Answer this question