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

if a union reaches 0 on the health bar. It disappears and an old union spawns in. It doesn't work?

I was trying to make if a union reaches 0 on the health bar. It disappears and an old union spawns in.

  local ClickDetector = game.Workspace.Union.ClickDetector
  local Textlabel = game.Workspace.Union.BillboardGui.TextLabel
  local OldUnion = game.ServerStorage:WaitForChild("OldUnion")
  local Union = game.Workspace.Union

  ClickDetector.MouseClick:Connect(function()
      Textlabel.Text = Textlabel.Text - 10
  end)

  if Textlabel.Text == 0 then
      Union.Transparency = 1
      Union.CanCollide = false
      Textlabel.TextTransparency = 1
      OldUnion.Parent = game.Workspace
      OldUnion.CFrame = Union.CFrame

  end 

1 answer

You are trying to minus a number from a string, you gotta make the string a number first,

TextLabel.Text = tonumber(TextLabel.Text) - 10

if tonumber(TextLabel.Text) == 0 then

and it should work as expected.

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