I want a achieve a backpack system, you get strength and what the value of the capacity is the value of strength should stay
The issue is when the value of strength is the same as the capacity value it stays but when you click it goes up but doesn’t show but when i sell and then get strength the value of how much times i click after shows
local plr = game.Players.LocalPlayer
script.AddPoints.OnServerEvent:Connect(function(player)
if player.leaderstats.Strength.Value == script.Capacity.Value then
game.Workspace.Event.Disabled = true
else if player.leaderstats.Strength.Value < script.Capacity.Value then
game.Workspace.Event.Disabled = false
end
end
end)
this is a little confusing because you make 2 functions in 1 ‘OnServerEvent’
maybe this script will help :
script.AddPoints.OnServerEvent:Connect(function(player)
local amount = 1
if player.leaderstats.Strength.Value >= script.Capacity.Value then
player.leaderstats.Strength.Value = script.Capacity.Value
else
player.leaderstats.Strength.Value = player.leaderstats.Strength.Value + amount
end
end
end)
script.AddPoints.OnServerEvent:Connect(function(player)
local amount = 1
local strengthValue = player.leaderstats.Strength.Value
local capacityValue = player.Capacity.Value
if strengthValue >= capacityValue then
strengthValue = capacityValue
else
strengthValue += amount
end
end)