Adding currency while a part touches another part

I want to add + 1 cash to my current leaderboard when a part called “cube” touches another part, like in a tycoon game. i’ve tried a lot of things but cant seem to make it work

save who owns the sell block (the part that when touched gives money) mainly buy the player pressing a button to “claim” then whenever something with a certain name and/or tag touches the sell block (add a debounce too) give money to the owner

thats not really what i meant, ill give some context as to what im making; its a factory like singleplayer game, i have parts on conveyors touching another part and then dissapearing, but how can i from the same script that makes the blocks dissapear, add cash to the player?

if its a singleplayer game then you can just take the player that is inside game.players and add to their leaderstat value

local conveyerEnd = script.Parent
local conveyerOwner = conveyerEnd:WaitForChild("ConveyerOwner")

conveyerEnd.Touched:Connect(function(Touched)
	if hit.Name == "ConveyerPart" then
		hit:Destroy()
		local Player = conveyerOwner.Value
		if Player then
			Player.leaderstats.Money.Value += 1
		end
	end
end)

Here’s a quick example, put an ObjectValue instance inside of the BasePart instance which is the end of the conveyor, assign to the Value property of this ObjectValue instance the player instance itself (of which owns the tycoon and thus the conveyor, you can do this when the player owns the tycoon), then use this player instance reference to increment their money/cash/credits/coins stat by some amount each time the conveyor end is touched by a part on the conveyor.

1 Like