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