I am trying to create a block of rice, that when you click, will give you rice. This does not seem to work, and I have looked all over for answers. I even found something similar on this site, but could not get it to work. Any help is appreciated!
function onClicked(clicked)
local h = clicked.Parent:FindFirstChild("Humanoid")
local l = h:findFirstChild("leaderstats")
local d = l:findFirstChild("Rice")
script.Parent.CFrame = script.Parent.CFrame*CFrame.new(0,-1,0)
script.Parent.Level.Value = script.Parent.Level.Value -1
d.Rice.Value = d.Rice.Value + 1
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

4 comments
What exactly is the problem?
It says that humanoid is nil
Why do you have a capital F for FindFirstChild, but the rest for findFirstCild are lowercase? Just wondering.
Typo, but that doesn't fix it. Thanks for pointing it out, though, will help!