#Button Activated refuses to work

1 messages · Page 1 of 1 (latest)

wary otter
#

Even MouseButton1Click does not work, which is causing me just all around confusion on why this button is being so difficult. I've double checked it's z index, heiarchy, and transparency which are all correct. Any help figuring this out would be appreciated <3

local Players = game:GetService("Players")
local RepS = game:GetService("ReplicatedStorage")

local LocalPlayer = Players.LocalPlayer
local playerGui = LocalPlayer.PlayerGui
local GUI = playerGui:WaitForChild("Menus").Inventory.GUI
local HUD = playerGui:WaitForChild("HUD").HUD
local itemTemplate = playerGui.Templates.ItemSlotTemplate

local invScroll = GUI.Pocket.invScroll

local itemsData = require(RepS.Shared.Data.itemData)
local getInventoryFunction = RepS:WaitForChild("remoteFunctions"):WaitForChild("getInventory")


local playerItems = getInventoryFunction:InvokeServer()

local openInvButton = HUD.MenuOptions.InventoryButton

-- Open the Inventory
openInvButton.Activated:Connect(function()
    GUI.Visible = not GUI.Visible
end)

-- Initalize the Inventory
for itemName , itemData in pairs (itemsData) do
    if itemData.Enabled == true then
        local newItem = itemTemplate:Clone()
        newItem.Visible = false
        newItem.Parent = invScroll
        newItem.NameButton.Text = itemName
        newItem.ImageButton.Image = itemData.Image
        newItem:AddTag(itemData.Class)
        newItem.NameButton:AddTag("invItem")
        newItem.ImageButton:AddTag("invItem")
    end
end

-- Load player items
if playerItems ~= nil then
    for itemName , itemData in pairs(playerItems) do
        if itemsData[itemName].Enabled == true then
            if itemData.uses > 0 then
                local item = invScroll:FindFirstChild(itemName)
                item.Visible = true
                item.usesLabel.Text = "x" .. itemData.uses
                item.own.Value = true
            end
        end
    end
end```
ebon flameBOT
#

studio** You are now Level 5! **studio

royal heron
wary otter
wary otter
wary otter
warm oyster
wary otter
warm oyster
#

You're most likely experiencing an infinite yield on the InvokeServer call, WaitForChild call, or require

warm oyster
#

They prevent ResetOnSpawn from working

wary otter
#

When you say surface-level, do you mean the top folders like Menus?

wary otter
warm oyster
wary otter
#

I will do that in a few minutes, eating lunch rn

wary otter
#

I am still new to scripting, so its possible I dont have the eye to notice it yet crying

#
local RepS = game:GetService("ReplicatedStorage")

local equipItem = RepS.remoteFunctions.equipItem
local useItem = RepS.remoteFunctions.useItem
local giveItem = RepS.remoteFunctions.giveItem

local buttonActions = {}

-- Connect inventory item to a command
function buttonActions.invItem(button)
    button.Activated:Connect(function()
        local canEquip = equipItem:InvokeServer(button.Parent.Name)
        local canUse = useItem:InvokeServer(button.Parent.Name)
    end)
end

return buttonActions```
#
local RepS = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local getInventoryFunction = RepS.remoteFunctions.getInventory
local equipItem = RepS.remoteFunctions.equipItem

getInventoryFunction.OnServerInvoke = function(player: Player)
    local inventoryData = playerInventoryData[player.Name]
    return inventoryData
end

equipItem.OnServerInvoke = function(player: Player, itemName: string)
    if playerInventoryData[player.Name][itemName].uses > 0 then
        return true
    else
        return false
    end
end```
#
local RepS = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local getInventoryFunction = RepS.remoteFunctions.getInventory

getInventoryFunction.OnServerInvoke = function(player: Player)
    local inventoryData = playerInventoryData[player.Name]
    return inventoryData
end```
#

heres the other scripts im using for this inventory service, just in case you wanted to see them

#

The equipItem and getInventoryFunctions are blank at the moment, since I have to figure out ProfileStore to actually start saving the player's inventory

warm oyster
#

Show me the module, @wary otter

wary otter
# warm oyster Show me the module, <@791450714433519617>
local RepS = game:GetService("ReplicatedStorage")

local equipItem = RepS.remoteFunctions.equipItem
local useItem = RepS.remoteFunctions.useItem
local giveItem = RepS.remoteFunctions.giveItem

local buttonActions = {}

-- Connect inventory item to a command
function buttonActions.invItem(button)
    button.Activated:Connect(function()
        local canEquip = equipItem:InvokeServer(button.Parent.Name)
        local canUse = useItem:InvokeServer(button.Parent.Name)
    end)
end

return buttonActions```
#

buttonActions atm just gives a command to the inventory items

warm oyster
#

Is Archivable enabled on your script?