I have it so that when you touch a part, it finds a value within the character and adds a preset amount that's found inside another value in the part.
debounce = false script.Parent.Touched:connect(function(hit) if debounce == false then debounce = true if hit.Parent:FindFirstChild("Humanoid") then if hit.Parent:FindFirstChild("money") then local money = hit.Parent:WaitForChild("money") local amount = script.Parent:WaitForChild("howmuchmoney").Value money.Value = money.Value + amount wait(.5) debounce = false end end end end)
Make sure that "money" is stored in the character and not the player. Also, add print()s every time you are unsure if the code reaches that point to see what went wrong. If the code reaches past line 6 but not past line 7, we know that hit.Parent:FindFIrstChild("money") is returning nil, so there's something wrong with that. This is a trivial question for you to debug yourself, just remember to use print statements and find your mistakes.
debounce = false script.Parent.Touched:connect(function(hit) if debounce == false then debounce = true print("First statement pass") if hit.Parent:FindFirstChild("Humanoid") then print("Second statement pass") if hit.Parent:FindFirstChild("money") then print("Third statement pass") local money = hit.Parent:WaitForChild("money") local amount = script.Parent:WaitForChild("howmuchmoney").Value money.Value = money.Value + amount wait(.5) debounce = false print("If it has reached this point, then it's working.") end end end end)