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

Is there any way to make this double coins gamepass script work better?

This double "coins" script works, but it gives 7x the amount of "coins" intended, so instead of giving 1 extra it gices 7. Is there any way I could make it just give 2?

local MS = game:GetService("MarketplaceService")
local VIPID = 8110615

local RS = game:GetService("ReplicatedStorage")

game.Players.PlayerAdded:Connect(function(plr)
	if MS:UserOwnsGamePassAsync(plr.UserId,VIPID) then
		
		plr:WaitForChild("leaderstats"):WaitForChild("Potatoes").Changed:Connect(function()
			plr.leaderstats.Potatoes.Value = plr.leaderstats.Potatoes.Value + 1
		end)
	end
end)






1 answer

This script I have made should give the gamepass owner 2 potatoes when they touch a coin or something.(Put the script inside your potato/coin.)

I have edited my answer.

Try this:

local MS = game:GetService("MarketplaceService")
local VIPID = 8110615

local RS = game:GetService("ReplicatedStorage")

script.Parent.Touched:Connect(function(plr, UserId)
    if MS:UserOwnsGamePassAsync(plr.UserId,VIPID) then

        plr:WaitForChild("leaderstats"):WaitForChild("Potatoes").Changed:Connect(function()
            plr.leaderstats.Potatoes.Value = plr.leaderstats.Potatoes.Value + 2 
            script.Parent:Destroy()
       end)
    else
         plr:WaitForChild("leaderstats"):WaitForChild("Potatoes").Changed:Connect(function()
            plr.leaderstats.Potatoes.Value = plr.leaderstats.Potatoes.Value + 2 
            script.Parent:Destroy()
        end)
    end
end)

Be aware I am new to scripting so this might not work...but at least try it to see.

If this worked for you or even helped you please accept this answer.

2 comments

0

Thank you, but if I use this script it will multiply their value which is not what I want. e.g if their value is 70, when they gain a coin their value will be 142, instead I am aiming to make it: if their value == 70 then they gain a coin their value would equal 72. Thanks for the answer though!

0

I have edited my answer.

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