How to make a textlabel change when person collected all items?

So basically, the game is like slender, when i collect 1 page i get a textlabel notification on my screen about how many pages i collected, but how do i change so when person collected 10 pages it gonna show “A Player has collected all pages” instead? not “A player has collected 10/10 pages” And i also wanted to change the sound when you collect the final page, it wont work.

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = player:WaitForChild("leaderstats")
	local cust = leaderstats:WaitForChild("Custards")
	local custgui = player.PlayerGui:WaitForChild("CustardCollected")
	local custtext = custgui:WaitForChild("TextLabel")
	local custsound = workspace:WaitForChild("CustardCollected")
	local amb = workspace:WaitForChild("Ambience")
	custtext.Text = "A Player has collected ".. cust.Value .. "/10 custards"
	if cust.Value == 10 then -- need help here, it wont show that player has collected all custards
		custsound.SoundId = "rbxassetid://140994215"
		custtext.Text = "A Player has collected all teletubby custards"
		amb:Stop()
	end
	cust.Changed:Connect(function()
		custgui.Enabled = true
		custtext.Text = "A Player has collected ".. cust.Value .. "/10 custards"
		wait(3)
		custgui.Enabled = false
	end)
end)

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = player:WaitForChild("leaderstats")
	local cust = leaderstats:WaitForChild("Custards")
	local custgui = player.PlayerGui:WaitForChild("CustardCollected")
	local custtext = custgui:WaitForChild("TextLabel")
	local custsound = workspace:WaitForChild("CustardCollected")
	local amb = workspace:WaitForChild("Ambience")
	custtext.Text = "A Player has collected ".. cust.Value .. "/10 custards"
	onChange = cust.Changed:Connect(function()
            if cust.Value >= 10 then
                custgui.Enabled = true
                custsound.SoundId = "rbxassetid://140994215"	    
                custtext.Text = "A Player has collected all teletubby custards"
                -- wait(3)
                -- custgui.Enabled = false
                amb:Stop()
                onChange:Disconnect()
            else
	        custgui.Enabled = true
                custtext.Text = "A Player has collected ".. cust.Value .. "/10 custards"
                wait(3)
	        custgui.Enabled = false
            end
	end)
end)
onChange = cust.Changed:Connect(function(newCust)
	if newCust >= 10 then
		custgui.Enabled = true
		custsound.SoundId = "rbxassetid://140994215"	    
		custtext.Text = "A Player has collected all teletubby custards"
		-- wait(3)
		-- custgui.Enabled = false
		amb:Stop()
		onChange:Disconnect()
	else
		custgui.Enabled = true
		custtext.Text = "A Player has collected ".. newCust.. "/10 custards"
		wait(3)
		custgui.Enabled = false
	end
end)

Don’t forget about Changed's implicit argument.

1 Like