Script doesn't do anything! (My script is not working but also not showing any errors)

So I am making a Baldi’s Basics game, I was trying to make it so that when you collect all notebooks (which in my case, are computers) the “Congratulations!” voice line plays,
but, for some reason, the script won’t do anything! It works but at the same time does not!

Here is my script:

game.Players.PlayerAdded:Connect(function(plr)
	local computers = plr:WaitForChild("leaderstats").Computers
	
	if computers.Value == 7 then
		game.Workspace.Congratulations:Play(2)
	end
end)

If there’s anything wrong in this script please tell me! Also yes, I know, it’s effortless indeed.

Your script checks the value only when the player joins, try printing the value first to see if it’s actually equal 7

2 Likes

That makes sense! Thank you for the help and I’ll make sure to never do such a stupid thing again!

No problem!
If you want the script to react to changes of the value you can do this

game.Players.PlayerAdded:Connect(function(plr)
	local computers = plr:WaitForChild("leaderstats").Computers
    computers.Changed:Connect(function(NewVal)
            if NewVal == 7 then
            game.Workspace.Congratulations:Play(2)
            end
    end)
	
end)
2 Likes

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