Stop counting when dead

use the updated one i edited my post

and put it in a local script

Now another one sadly

I put this script inside the textlabel right?

local count = 0
local counting = true

task.spawn(function()

  while true do
    if counting == true then count += 1 end
    task.wait(1)
  end

end)

local plr = game.Players.LocalPlayer -- this only work in a local script

--when dies
plr.Character.Humanoid.Died:Connect(function()
  counting = false
end)

--when they spawn
plr.CharacterAdded:Connect(function()
  counting = true
end)

Doesnt even give me a fail output this time.

do i put this instead of the old script or use both? I tried both but just to be sure

that means its working but i didnt add anything to change the text

you have to change the text now when you change t he counter

local count = 0
local counting = true

task.spawn(function()

  while true do
    if counting == true then count += 1 end
    script.Parent.Text = tostring(count)
    task.wait(1)
  end

end)

local plr = game.Players.LocalPlayer -- this only work in a local script

--when dies
plr.Character.Humanoid.Died:Connect(function()
  counting = false
end)

--when they spawn
plr.CharacterAdded:Connect(function()
  counting = true
end)
1 Like

Before i try that i tried mixing the two together and made this but it only counts and doesnt stop local count = 0
local counting = true

while counting and count < 10000000000000000000000000000000000000000 do
wait(1)
script.Parent.Text = tostring(count)
count = count + 1
end

local plr = game.Players.LocalPlayer – this only work in a local script

–when dies
plr.Character.Humanoid.Died:Connect(function()
counting = false
end)

Also no need to add when spawned. I removed spawning back in straight up. Made the respawn time inf

It worked!! Thanks a ton! Have been trying to figure it out for too long :sob:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.