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

Buy button for shop won't update correctly, how do I fix??

Asked by 4 years ago

So, in my game, I have a shop. The buy button is supposed to update to "Equip," "Equipped," etc, but it doesn't work right. Even if the player's equipped value is a certain skin, it won't say equipped! Client - side script:

boxName:GetPropertyChangedSignal("Value"):Connect(function()

    local model = nil

    for i, object in pairs(game.Workspace.Shop.ItemRoller["Box"..boxName.Value]:GetChildren()) do
        if object:IsA("Model") then
            model = object
        end
    end

    local toolsBought = game.ReplicatedStorage.GetSkinsBought:InvokeServer()

    for i, tool in pairs(toolsBought) do
        if tool == model.Name then
            script.Parent.Text = "Equipped"
        else
            script.Parent.Text = "Equip"
        end
    end

    print(script.Parent.Text)

end)

(The parent is the button.)

Server - side:

game.ReplicatedStorage.GetSkinsBought.OnServerInvoke = function(player)

    local tools = {}

    for i, tool in pairs(game.ServerStorage.PlayerSkins[player.Name]:GetChildren()) do
        table.insert(tools,tool.Name)
        print(tool)
    end

    return tools

end

HELP

1 answer

Log in to vote
0
Answered by
Farsalis 369 Moderation Voter
4 years ago
Edited 4 years ago

In your assignment to model, you try to get "model.Name", but that doesn't exist outside of the for loop (Since your trying to explicitly get the object..which you have no reference to), thus it actually turning out to be nil. Since your trying to grab the name anyways, just store within model "object.Name". That should do it. If not, please comment.

Hope This Helped.

Ad

Answer this question