i am working on a game and when i go over the money it wont change my leader board, or delete the brick for that matter, if you could help that would be much appreciated! i updated the code to how it is now
math.randomseed(tick())
local ting = 0
function onTouched(hit)
if ting == 0 then
ting = 1
local check = hit.Parent:FindFirstChild("Humanoid")
if check then
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local stats = user:FindFirstChild("leaderstats")
if stats then
local randomNumber = Random.new():NextNumber(5,10)
local cash = stats:FindFirstChild("Money")
cash.Value = cash.Value + randomNumber
end
end
ting = 0
end
end
script.Parent.Touched:Connect(onTouched)
script.Parent.Parent:Destroy()

2 comments
This won't help fix your code, but I can't stress this enough; findFirstChild() should be FindFirstChild() on line 14, you don't have to put if obj ~= nil then, you can do if obj then(this applies for lines 11 and 16); connect() is deprecated, use Connect(). Plus, please indent.
You should also be using the new userdata, Random(that was added last year I think), as it is much more faster than math.random(). You can use it like this if you want a random integer: Random.new():NextInteger(min,max) ;or, if you want a random number: Random.new():NextNumber(min,max) (NextNumber() can also return decimals)