I just created this Backpack system it works just fine but after I buy the tool that gives 100 points it breaks down and goes above the capacity value:
Script in workspace
local player = game.Players.LocalPlayer
local CapacityValue = 20
script.AddHydration.OnServerEvent:Connect(function(player)
if player.leaderstats.Hydration.Value >= script.Capacity.Value then
player.leaderstats.Hydration.Value = player.leaderstats.Hydration.Value - CapacityValue
game.Workspace.MainEvent.Disabled = true
else if player.leaderstats.Hydration.Value < script.Capacity.Value then
game.Workspace.MainEvent.Disabled = false
end
end
end)
Script inside of tool
local cooldown = false
script.Parent.Activated:Connect(function()
if cooldown == false then
cooldown = true
game.Workspace.Backpack.AddHydration:FireServer()
script.Parent.Enabled = false
wait(1)
script.Parent.Enabled = true
cooldown = false
end
end)
You could add a script that says, if the item value is more than the backpacks capacity value then the player cant buy it, because they do not have enough space.
Uhm I guess you did not understand what the system does it’s buy it, it is basically that if the points value is equal to 20 then you can click anymore
Ok I’m sorry I understood what you wanted to tell,But I want the players to be free and buy anything unlike other games where they have to buy unlocked things and not locked things
[quote=“setis2222, post:16, topic:1603341, full:true”]
If player.leaderstats.Hydration.Value > script.Capacity.Value then
Player.leaderstats.Hydration.Value = script.Capacity.Value
Ya I tried this but not working
local player = game.Players.LocalPlayer
local CapacityValue = 20
script.AddHydration.OnServerEvent:Connect(function(player)
if player.leaderstats.Hydration.Value >= script.Capacity.Value then
player.leaderstats.Hydration.Value = script.Capacity.Value
game.Workspace.MainEvent.Disabled = true
else if player.leaderstats.Hydration.Value < script.Capacity.Value then
game.Workspace.MainEvent.Disabled = false
end
end
end)