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

Im trying to make a backpack script but Wheat does not seem to increase in value on the textlabel?

Asked by 5 years ago
local BackPack = script.Parent.BackPack

local Player = game.Players.LocalPlayer

local Wheat = Player.leaderstats.Wheat

local Storage = script.Parent.Storage.Value

local Storage = "25"



BackPack.Text = Player.leaderstats.Wheat.Value.."/"..Storage

if Wheat.Value == Storage then return end

1 answer

Log in to vote
0
Answered by 5 years ago

This is because you have only set the textlabel once in the script meaning it would only run once. If you want it to change: use the Changed event like this:

    local BackPack = script.Parent.BackPack

    local Player = game.Players.LocalPlayer

    local Wheat = Player.leaderstats.Wheat

    local Storage = script.Parent.Storage.Value

    local Storage = "25"



    BackPack.Text = Player.leaderstats.Wheat.Value.."/"..Storage
    Wheat.Changed:Connect(function() -- when wheat changes it will fire this function
        BackPack.Text = Player.leaderstats.Wheat.Value.."/"..Storage
    end)

    if Wheat.Value == Storage then return end
0
Thank you very much! Narrowlegobricks 12 — 5y
Ad

Answer this question