Why is it selling for double?

So basically, earlier I went to devforum for help on making a 2x money gamepass. That worked for the most part, but only one thing was amiss. Everything sells for double now. I think its an easy fix, im just new to scripting and don’t know how to do it. And @2112Jay made this for me! Thanks!

local MarketPlaceService = game:GetService(“MarketplaceService”)
local doublePass, gamepassID = false, 107510236

function Spawned(player)
local HasGamepass = false
local success, message = pcall(function()
HasGamepass = MarketPlaceService:UserOwnsGamePassAsync(player.userId, gamepassID)
end)

task.wait(1)
if not success then
	warn("Checking Gamepass "..tostring(message))
	return
else
	doublePass = true
end

end

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
task.wait(3) Spawned(player)
end)
end)

script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local leaderstats = player:WaitForChild(“leaderstats”)
local money = leaderstats:FindFirstChild(“Money”)
local Sap = leaderstats:FindFirstChild(“Sap”)

	if Sap.Value > 0 then
		local pay = Sap.Value
		if doublePass then pay *= 2 
		end
		money.Value += pay
		Sap.Value = 0
	end
end

end)

Thanks in advance!

1 Like
if doublePass then pay *= 2

Perhaps this is your issue?

Maybe… i can try something else

You’re using DoublePass outside of the function Spawned, that’s a problem too.

You can use a RemoteEvent to Check and give the Player the coins

Maybe do a function with this if statement?

function Pass(Gamepass: number)
if Gamepass == "Your Gamepass" then
 -- code
return -- Ends function
end
end
1 Like

sorry wrong reply person … I’ll re-post

Ok… ill start combing through the code

Didn’t you want a 2x money gamepass?
or did you want a 1/2 off game pass … replace *=2 for /=2

i want a 2x money gamepass so it would be *=2 pretty sure right?

You said it works, only problem is it’s charging double. I thought when you touched something it gave you x2 money as in a x2 money gamepass. So the problem is the *=2 Change that to /=2 as this must be being used to buy something, with a 1/2 off game pass. No matter what name you’re calling it, in this case it’s taking 1/2 off the price not giving x2.

it seems like Sap is used for both receiving money and buying items, so when you times it by two it will also double the cost of an item

you need a seperate script or function that is only for giving the player money and then you can double the value for that

Sap is something that you added from some other place. No explanation was given. I’m still not sure how you’re using this script. To me, Sap sounds like something that happen from a hit.