local Players = game.Players local moeda = script.Parent local function onPartTouched(otherPart) local parent = otherPart.Parent local humanoid = parent:FindFirstChildWhichIsA("Humanoid") if humanoid then moeda.Destroy() local player = Players:GetPlayerFromCharacter(parent) local leaderstats = player.leaderstats local moneyStat = leaderstats and leaderstats:FindFirstChild("Money") if moneyStat then moneyStat.Value += 10 end end end moeda.Touched:Connect(onPartTouched())
attempt to index nil with 'Parent'
https://prnt.sc/V326_gNGrKqS https://prnt.sc/tUETY7aBKM_P
You're trying to connect the Touched event to the result of the onPartTouched function which is nil. Remove the parentheses to pass the function value instead of the result of the function and it should work as expected.
moeda.Touched:Connect(onPartTouched)