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

Making A Scoreboard that keeps counting until you die?

I'm trying to figure out how to make a scoreboard that doesn't stop counting until you die.

wait()
local a = 0
local c = script.Parent.Text

game.Players.PlayerAdded:connect(function(p)
	p.CharacterAdded:connect(function(char)
		if char:FindFirstChild("Humanoid").Health >= 100 then
			while true do
				a = a+1
			c = "High Score: "..a
			end
		elseif char:FindFirstChild("Humanoid").Health == 0 then
			script.Parent.Text = a
		end
	end)
end)

2 answers

Hello, SnakeInTheBoots!

I made some little changes in your script:

wait()
local a = 0
local c = script.Parent.Text

game.Players.PlayerAdded:connect(function(p)
    p.CharacterAdded:connect(function(char)
        if char:FindFirstChild("Humanoid").Health >= 100 then
            while true do -- I think you forgot a wait() somewhere here....
                a = a+1
            c = "High Score: "..a
	        if char.Humanoid.Health == 0 then break end -- Breaks the Loop if the health is equals to 0
            end
	-- Removed some not needed lines...
	script.Parent.Text = a
    end)
end)

Good Luck with your games

1 comment

0

You should explain your answer. Otherwise, OP won't learn anything.

--make sure it is a local script and in the right place to fit "c"
--shouldn't be in workspace

wait()
local a = 0
local c = script.Parent.Text
local plr = game.Players.LocalPlayer
repeat wait()until plr.Character
repeat
	a = a + 1
	wait(1) -- number of seconds to wait until 1 is added to a
	c = "High Score" ..a -- I don't understand but you're making the script so we'll keep it
until plr.Character.Humanoid.Health == 0
script.Parent.Text = a

-- please tell me if it doesn't work and I'll try improving it

3 comments

0

doesn't work :(

0

nvm I got it to work..

0

This is a little bit fake, it don`t updates to the server the count, so it just gives the result to the local player... You NEED to use Remote Functions or a Server Script

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