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

My Sell Area Code Still Won't Sell The Items For Currency Can Someone Help Me?

Asked by
zpfran -25
5 years ago

The script is supposed to detect when the player touches the brick or part that is inside the sell and if the players has more than 1 duck or item than it will sell depending on the rebirth amount, then the item amount should go back to 0 and you get your cash.

local Part = script.Parent
Part.Touched:Connect(function(HIT)
    local H = HIT.Parent:FindFirstChild("Humanoid")
    if H then
        local player = game.Players:WaitForChild(HIT.Parent.Name)
        if player then
            local leaderstats = player:WaitForChild("leaderstats")
            local currency = leaderstats.Cash
            local selling = leaderstats.Ducks
            if selling.Value > 0 then
                currency.Value = currency.Value + selling.Value * 1 * (leaderstats.Rebirth.Value +1)
            end
        end
    end
end)
0
It Still Isn't Working zpfran -25 — 5y
0
oh? TheRealPotatoChips 793 — 5y
0
ya IDK why? zpfran -25 — 5y
0
answer down here, if it didn't work, please say what's not working. TheRealPotatoChips 793 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

Try this:

local Part = script.Parent
    Part.Touched:Connect(function(HIT)
        local H = HIT.Parent:FindFirstChild("Humanoid")
        if H then
            local player = game.Players:WaitForChild(HIT.Parent.Name)
            if player then
                local leaderstats = player:WaitForChild("leaderstats")
                local currency = leaderstats.Cash
                local selling = leaderstats.Ducks
                if selling.Value > 0 then
                    currency.Value = currency.Value + selling.Value * (leaderstats.Rebirth.Value +1)
            selling.Value = selling.Value - selling.Value
                end
            end
        end
    end)

0
oh ok zpfran -25 — 5y
Ad
Log in to vote
0
Answered by
zpfran -25
5 years ago

Like This?

local Part = script.Parent
Part.Touched:Connect(function(HIT)
    local H = HIT.Parent:FindFirstChild("Humanoid")
    if H then
        local player = game.Players:WaitForChild(HIT.Parent.Name)
        if player then
            local leaderstats = player:WaitForChild("leaderstats")
            local currency = leaderstats.Cash
            local selling = leaderstats.Ducks
            if selling.Value > 0 then
                currency.Value = currency.Value + selling.Value * 1 * (leaderstats.Rebirth.Value +1)
selling.Value = 0
            end
        end
    end
end)
0
? zpfran -25 — 5y
0
I think yes TheRealPotatoChips 793 — 5y
0
it still wont work :( zpfran -25 — 5y
0
DUDE STOP COPYING TheRealPotatoChips 793 — 5y

Answer this question