Why is my script not working?

Hello, i am making developer product, if you buy it. You get cash

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

Any ideas how to make it work?

1 Like

you added quotation marks that probably messed up the whole script.

No no, the quotation are normally productids.

No, I’m saying you covered a whole part of your script with the quotation marks.

I noticed that you put

else if if productId =

It should be

elseif productId =

I don’t know if that’s your issue but I saw that.

Lets say its gonna be

if productId == 1081531257 then
		local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
			if cashmoney then
			cashmoney.Value = cashmoney.Value + 1000
		else if
				if productId == 1081532168 then
		local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
			if cashmoney then
			cashmoney.Value = cashmoney.Value + 10000
				
			end
		``` 
it will still not work without those "

whys are you going to the server storage for player money? shouldn’t it be inside of the player? That would make this a whole lot easier

Still not working

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

still not working :frowning:

I agree with @sniper74will, the money should probably be inside the player rather than ServerStorage.

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

you were missing multiple ends in your script

1 Like

Okay so the +1000 one works, but the second one still dont work :frowning:

this may sound stupid, but are you sure its the right product id?

Yea im sure xD, it pops up but doesnt add the cash :smiley:

I don’t see anything wrong with the script, they are both the exact same. They both should work

1 Like

The issue is the nesting of your if statements.

if productId == 1081526157 then
	local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
	if cashmoney then
		cashmoney.Value = cashmoney.Value + 1000		
	end	
	
elseif productId == 1081532144 then
	local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
	if cashmoney then
		cashmoney.Value = cashmoney.Value + 10000
	end
end
3 Likes

if’s and elseif’s are supposed to be attached to the same ‘end’ and on the same line.

I tried but nope, not working :frowning:

You need to press ok for it to go through im pretty sure.

Open the console and let us know what errors you are getting