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

Is this right?

Asked by 11 years ago

I'm trying to get it so that it saves the item's name and the item's number in a value (The item is a GUI button, and the value is inside the button called NumberValue)

-- Save

local Players = game:GetService("Players")

01Players.PlayerAdded:connect(function(Plr)
02    Plr.Backpack.ChildAdded:connect(function(Item)
03        if Plr.DataReady then
04            for _, v in pairs(Plr.PlayerGui.Inventory.Frame.Items:GetChildren()) do
05                if v ~= nil then
06                    Plr:SaveString(v.Name,v.Name)
07                    Plr:SaveNumber(v.Name,v.NumberValue.Value)
08                end
09            end
10        end
11    end)
12end)
13 
14Players.PlayerRemoving:connect(function(Plr)
15    if Plr.DataReady then
View all 23 lines...

-- Load

01game:GetService("Players").PlayerAdded:connect(function(Plr)
02    Plr.CharacterAdded:connect(function(Char)
03        Plr:WaitForDataReady()
04 
05        local last = {}
06        local lastposition = UDim2.new(0, 0, 0, 0)
07        for _, v in pairs(game:GetService("ReplicatedStorage").Buttons:GetChildren()) do
08            if Plr:LoadString(v.Name) == v.Name then
09                if (last) then
10                print(Plr:LoadString(v.Name))
11                cl = v:Clone()
12                cl.Parent = Plr.PlayerGui.Inventory.Frame.Items
13                cl.Position = UDim2.new(0, 14, 0, 0) + lastposition
14                Plr.PlayerGui.Inventory.NumberOfItems.Value = Plr.PlayerGui.Inventory.NumberOfItems.Value +1
15                cl.NumberValue.Value = Plr:LoadNumber(v.Value)
View all 23 lines...

1 answer

Log in to vote
0
Answered by 11 years ago

You need to share a more detailed issue, just asking if it's right doesn't help us, we need output codes from the game.

0
Oh, right. Well generally the problem is loading the number value to the button. It usually says "Value is not a valid member of TextButton" which is on line 15 of the load. geckohero17 55 — 11y
Ad

Answer this question