I need help with this script

  1. I want a achieve a backpack system, you get strength and what the value of the capacity is the value of strength should stay

  2. 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

https://gyazo.com/32294d77a8aa94aef37d9a8e3bf74d1d

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)

Thank you

1 Like

I could show more information if you want

game.Workspace.Event.Disabled = true

Is ‘Event’ a script?.

yes even is a script do you want me to show you

If you can show me why not, it will make me understand better where the problem is.

script.AddPoints.OnServerEvent:Connect(function(plr)

plr.leaderstats.Strength.Value = plr.leaderstats.Strength.Value +1

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)

it wont work because capacity is not a valid member of the script

bruh You copy and paste this script in the script that has ‘Capacity’

thank you that really helped :slight_smile:

no problem happy to help and happy to see you can solve your problem:)

java it works but now the value stops at 11/10

can you send me a video? I want to see how the problem is

it doesnt matter it works now thank you

You can further optimize the script.

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)

(Written by R0bl0x10501050 on alt)

You are welcome :slight_smile:

@JavaKingz quick question do you know how to make this save?

@Official_ProGamerYT save for Capacity value?

You would use datastores, but yes saving is an option.

You would most likely want to save in your PlayerAdded serverscript in SSS.

yes the capacity value when you leave and join back it saves