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

How to make a backpack stop getting filled up when you max it out?

Asked by 4 years ago
Edited 4 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

Hello,

All my questions keep getting closed I am a bad scripter don't know how to script that good. So I am here for you guys to tell me everything that's wrong with my script so I can get better and learn.

game.Workspace.sell.Part.Touched:Connect(function()
    stat.Value = 25
end)

The stat value is the Bag value in my leaderboard I am trying to make it so when someone reaches 25 it will stops or if they go over and try to sell that they only get 25.

0
I don't get what you are asking for, so when you touch a part, it sells up to a maximum of 25? superbolt999 36 — 4y
0
No if you have over 25 in your stat then it will only sell for 25 so something like what I did when you touch the sell brick it makes it so you get only 25 in your stat witch sells and you get 25 cash. Darthman522 10 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

so here is the program that will do it

local debounce = false
function sell(part)
    if part.Parent:FindFirstChild("Humanoid") and debounce == false then
        debounce = true
        local player = game.Players:GetPlayerFromCharacter(part.Parent)
        local material = player.leaderstats.stat.Value
        if material < 25 then
            wait(3)
            debounce = false
        else
            material = material-25
            player.leaderstats.stat.Value = material
            wait(3)
            debounce = false
        end
    end
end
game.Workspace.sell.Part.Touched:Connect(sell)

I don't know if this is what you were trying to do but good luck!

Ad

Answer this question