Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Backpack indicator not working when collecting an item (coin, brick, whatever)?

i have a screen gui with a frame and two text labels named "Indicator" and "TextLabel".

the text label contains the "Backpack" name

the indicator is to display the number of an item out of 10, 25, 50, 100, etc

like this:

Backpack 0/10

the script is a local script inside of the indicator text label. there are no errors showing in the output, but it wont print anything either lol

here is my script:

local player = game.Players.LocalPlayer
local char = player.Character

player.CharacterAdded:Connect(function()
	local Backpack = player:WaitForChild("BackpackShop").Backpack.Value
	local Bricks = player.leaderstats.Bricks
	script.Parent.Indicator.Text = Bricks.Value.."/"..Backpack.Value
	
	
	Backpack.Changed:Connect(function()
	script.Parent.Indicator.Text = Bricks.Value.."/"..Backpack.Value 
	end)
	
	Bricks.Changed:Connect(function()
	script.Parent.Indicator.Text = Bricks.Value.."/"..Backpack.Value
	
	end)
end)

1 answer

✓ Accepted answer

Hello, ChemicalWolf!

local player = game.Players.LocalPlayer
local char = player.Character

player.CharacterAdded:Connect(function()
    local Backpack = player:WaitForChild("BackpackShop").Backpack.Value
    local Bricks = player.leaderstats.Bricks
    script.Parent.Indicator.Text = Bricks.Value.."/"..Backpack  --Don't need .Value again


    Backpack.Changed:Connect(function()
    script.Parent.Indicator.Text = Bricks.Value.."/"..Backpack  --Don't need .Value again
    end)

    Bricks.Changed:Connect(function()
    script.Parent.Indicator.Text = Bricks.Value.."/"..Backpack --Don't need .Value again

    end)
end)

EDIT:

local player = game.Players.LocalPlayer
local char = player.Character

player.CharacterAdded:Connect(function()
    local Backpack = player:WaitForChild("BackpackShop").Backpack.Value
    local Bricks = player.leaderstats.Bricks
    script.Parent.Indicator.Text = Bricks.Value.."/"..Backpack  --Don't need .Value again


    Backpack.Changed:Connect(function()
    Backpack = player:WaitForChild("BackpackShop").Backpack.Value
    script.Parent.Indicator.Text = Bricks.Value.."/"..Backpack  --Don't need .Value again
    end)

    Bricks.Changed:Connect(function()
    Bricks = player.leaderstats.Bricks
    script.Parent.Indicator.Text = Bricks.Value.."/"..Backpack --Don't need .Value again

    end)
end)

7 comments

0

sadly this didnt work

1

Strange... Any errors on console?

0

nothing, which is surprising

1

try addind prints on almost all lines of your code: Add on line 6, to check the variable 'Backpack', add on line 7, to check the variable 'Bricks' and on line 10 and 14 also

0

Reading the code again, I think I know what the error is, I'll edit que answer

0

still not working, it only printed after i set the variables. i'm just gonna start from the beginning because i feel there is something wrong in another script or something lol

0

lll mark it as solved since im pretty sure nobody else in the world will have this same issue

This discussion is preserved as it was. New answers, comments, and votes are closed.