Help with my sell point

Hello!

I need some help with my sell point. I am trying to make it so the players can sell a leaderstat, for example Points, and get another stat, let’s say Coins.

So when the player sells 5 points, they get 5 cash. But, with this script, there’s multipliers so when you sell you will get 10 cash instead.

Well, I am also trying to make it so if you have a gamepass, it gives a better multiplier.

Here’s the script:

local SellPart = script.Parent
local ID = 82114987
SellPart.Touched:Connect(function(hit)
    local H = hit.Parent:FindFirstChild("Humanoid")
    if H then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player then
            local leaderstats = player:WaitForChild("leaderstats")
            local Currency = leaderstats.BromineElement
            local Selling = leaderstats.Cash

            if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, ID) then
                if Selling.Value > 0 then
                    Currency.Value = Currency.Value + Selling.Value * 4
                    Selling.Value = 0
                end
            else
                if Selling.Value > 0 then
                    Currency.Value = Currency.Value + Selling.Value * 2
                    Selling.Value = 0
                end
            end
        end
    end
end) 

Nothing appears in the output, and it doesn’t give any cash.

Try this:

--//Services
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")

--//Variables
local SellPart = script.Parent

--//Controls
local GamepassId = 82114987

--//Functions
SellPart.Touched:Connect(function(hit)
	local Player = Players:GetPlayerFromCharacter(hit.Parent)
	
	if not Player then
		return
	end
	
	local leaderstats = Player:WaitForChild("leaderstats")
	local Currency = leaderstats.BromineElement
	local Selling = leaderstats.Cash
	
	if Selling.Value > 0 then
		print("Value is over 0")
		
		if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) then
			Currency.Value += Selling.Value * 4
		else
			Currency.Value += Selling.Value * 2
		end
		
		Selling.Value = 0
		
		print("Completed")
	end
end)

Tell me if it prints anything.

1 Like