Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a pet Multiply the amount of item your selling?

Asked by 5 years ago

so im just ganna explain my problem. so i am working on a game currently and inside the game you are supposed to collect items that get stores into your backpack which has a limited space of how many of those items you can store then you are supposed to go to a small area when if you character stands it will sell those items automatically and get exchanged money, like if you have collected wood which is in my game you sell it and get money in return. so then i next added a pet shop and it works fine you bu the pets and i tried adding a script so when you go to sell your wood for money you get x2 of the income so instead of selling 50 wood for 50 money you get 100 cash for 50 wood. so inside the pet i added this script:

workspace.BackpackShop.Sell.Part.Script(function(Hit)
    local Player = game.Players:FindFirstChild(Hit.Parent.Name)
    if Player then
        local leaderstats = Player:FindFirstChild("leaderstats")
        if leaderstats then
            local Money = leaderstats:FindFirstChild("Money")
            local Backpack = leaderstats:FindFirstChild("Wood")
                if Backpack.Value <= 0 then
                else
                Money.Value = Money.Value + 2 * Backpack.Value
                Backpack.Value = 0
                script.Disabled = true
                wait(0.1)
                script.Disabled = false
                end
            end
        end
end)

which is the same script but i tried to make it so if you have this pet the money value gets added by the x2 the amount of wood.

script inside of selling area that player steps on to sell wood:

script.Parent.Touched:connect(function(Hit)
    local Player =          game.Players:FindFirstChild(Hit.Parent.Name)
    if Player then
        local leaderstats = Player:FindFirstChild("leaderstats")
        if leaderstats then
            local Money = leaderstats:FindFirstChild("Money")
            local Backpack = leaderstats:FindFirstChild("Wood")
                if Backpack.Value <= 0 then
                else
                Money.Value = Money.Value + 1 * Backpack.Value
                Backpack.Value = 0
                script.Disabled = true
                wait(0.1)
                script.Disabled = false
                end
            end
        end
end)

so can anyone help me and tell me whats wrong?

0
Why are you adding 1 to it? Why not just multiply it by 2? DeceptiveCaster 3761 — 5y
0
im not adding 1 im multiplying by 1 so for every wood sold multiply by 1 and give that much cash in return so if i sell 50 wood multiply by 1 and get 50 cash, what im trying to do is like if youve seen in some simulator games they have pets that have a multiplier that gives x2 cash is what im trying to do. so if you have a pet it gives you x2 the income which is what i tried doing ahsan666666666666 264 — 5y

Answer this question