Cash script doesn't work

Hello, so idk why the script doesn’t work

  1. I want that the script give the player cash when he purchase the devproduct, and script works, until I try to add a second dev product :sleepy:

  2. When I try to add the second dev product doesn’t work heres Is the script

if productId == 1087168544 then
	local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
		if cashmoney then
			cashmoney.Value = cashmoney.Value + 1000
		end
  1. I try doing in a different way, but the game is a tycoon, so doesn’t have a direct leaderstat script. :upside_down_face:
1 Like

Did you place the script in ServerScriptService?

yes, I place it in server script service

Do you have Third Party Sales enabled? If you do not, in your game settings go to settings and then enable Third Party Sales.

Ok is enabled, now it have to work?

Tell me if it works @JaviRoak

Thanks,
HDAdminUnofficial

If it does not work, tell me. I have another way to solve the issue.

doesn’t work, but Idk if is the script when I try to add another dev product with different number of cash

@JaviRoak Alright. Thanks for telling me that it didn’t work.

To make the script work, you must create a new script with the script in it.

If this didn’t work, tell me.

So it will see like this?

if productId == 1087168544 then
local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
if cashmoney then
cashmoney.Value = cashmoney.Value + 1000
end

if productId == 1087168544 then
local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
if cashmoney then
cashmoney.Value = cashmoney.Value + 1000
end

Yes, exact same script in the new script.

@HDAdminUnofficial @JaviRoak There are 2 things I should point out:

  1. You can only set a function to a callback once.
  2. Creating a new script and pasting the original script’s source will not do anything other than resetting the properties of the script.

Now for the actual solution, you can just attach elseifs to the if statement.

if productId == 1087168544 then
    local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
    if cashmoney then
        cashmoney.Value = cashmoney.Value + 1000
    end
elseif productId == 123 then -- replace 123 with the id
    local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
    if cashmoney then
        cashmoney.Value = cashmoney.Value + 1000 -- replace 1000 with the respective amount
    end
end

By the way, you can just do cashmoney.Value += 1000 instead of rewriting the path again.

2 Likes

it works! thank you so much :smiley:

1 Like