this script is not working and can someone please explain why? Because when I changed (randomnumber) to 1, it added one match to the leaderstats, so the problem is in a random number
local randomnumber = math.random(1,6) script.Parent.ClickDetector.MouseClick:Connect(function(ply) ply.leaderstats.Matches.Value = ply.leaderstats.Matches.Value + (randomnumber) end)
Your problem is that you generate the random number once to add it to a variable. In order to fix this, simply just add the variable inside the MouseClick so it generates a new one each time.
script.Parent.ClickDetector.MouseClick:Connect(function(ply) local randomnumber = math.random(1,6) ply.leaderstats.Matches.Value = ply.leaderstats.Matches.Value + (randomnumber) end)