Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Money script is only giving $25 dollars per second when touched for money?

I tried to make a script which gives you $25 per part but when you touch it, it gives you $25 per second which is not what I wanted. Please help my by telling me what to edit or edit it yourself.

points2 = game.Workspace.Table.Value

script.Parent.Shop.Part.Touched:Connect(function(hit)
	if points2.value >= 1 then
		if hit.Parent:FindFirstChild("Humanoid") ~= nil then
        	player = game.Players:GetPlayerFromCharacter(hit.Parent)
			player.leaderstats.Money.Value = player.leaderstats.Money.Value + 25
		end
		
		points2.Value = points2.Value - 1

	end
end)

4 comments

0

aaaaaaaaaaaaaaaaaaaaaaaaaa, the 7...

0

add a debounce

0

Whats debounce?

0

What I was talking about is that is not giving all the money to you at once like if I have ten parts if i go to collect the money it takes ten seconds. But i'm not getting extra money.

1 answer

It is probably because you are touching the part too many times which means it will add money every time it detects a touch. Maybe add a wait function:

points2 = game.Workspace.Table.Value

script.Parent.Shop.Part.Touched:Connect(function(hit)
    if points2.value >= 1 then
        if hit.Parent:FindFirstChild("Humanoid") ~= nil then
            player = game.Players:GetPlayerFromCharacter(hit.Parent)
            player.leaderstats.Money.Value = player.leaderstats.Money.Value + 25
	    wait(10)
        end

        points2.Value = points2.Value - 1

    end
end)

1 comment

0

What I was talking about is that is not giving all the money to you at once like if I have ten parts if i go to collect the money it takes ten seconds. But i'm not getting extra money.

This discussion is preserved as it was. New answers, comments, and votes are closed.