#attempt to call missing method 'buttonSelect' of table -

1 messages · Page 1 of 1 (latest)

jaunty maple
#

anyone know why I'm getting this error trying to call buttonSelect in my localscript

local selectColorUI = script.Parent
local selectFolder = selectColorUI:WaitForChild("Select")
local colorSelection = require(game.ReplicatedStorage.Framework.Client.Controllers.UIController.RoundUI.ColorSelection)

print(colorSelection)

local buttons = {}

for i, child in ipairs(selectFolder:GetDescendants()) do
    print("iterating")
    if child:IsA("ImageButton") then
        buttons[i] = child
        print("found button")
        print(buttons[i])
    end
end

for i, button in pairs(buttons) do
    button.MouseButton1Click:Connect(function()
        colorSelection:buttonSelect(button)
    end)
end```
jaunty maple
#
local function buttonSelect(button)
        button.MouseButton1Click:Connect(function()
            local folderContainer = button.Parent.Parent
            folderContainer.Parent = noneSelected[1]
            table.remove(noneSelected,1)
        end)
    end
end``` this function, all the way at the bottom of the module
#

and I try to call it

right here

for i, button in pairs(buttons) do
    button.MouseButton1Click:Connect(function()
        colorSelection:buttonSelect(button)
    end)
end```
coarse fern
#

oh wait no

#

well yes but also

#
local function buttonSelect(button)
        button.MouseButton1Click:Connect(function()
            local folderContainer = button.Parent.Parent
            folderContainer.Parent = noneSelected[1]
            table.remove(noneSelected,1)
        end)
    end
#

this code creates a function, but its not actually assigned to color selection

#

This line of code actually makes your function buttonSelect() part of the colorSelection table

function colorSelection.buttonSelect(button)
        button.MouseButton1Click:Connect(function()
            local folderContainer = button.Parent.Parent
            folderContainer.Parent = noneSelected[1]
            table.remove(noneSelected,1)
        end)
    end
#

then it should work

coarse fern
jaunty maple
#

alr

coarse fern
jaunty maple
#

trying it now

#

yea it worked

gilded pollenBOT
#

studio** You are now Level 1! **studio

jaunty maple
#

I also got another semi-error

#

its weird cuz sometimes I get it during run time sometimes I don't

#

I'm pretty sure it has something to do with the timing of things loading

coarse fern
#

probably whats the error?

jaunty maple
#
self.Remotes.RequestColorSelection:FireAllClients()``` sometimes it says I'm trying to index FireAllClients() with nil
#

sometimes it runs without a problem

#

when I define it I use WaitForChild()

coarse fern
#

when you define it?

#

wdym

jaunty maple
#

yea the instance of my dependency table

#

I'll show you 1 sec

#

local StartColorSelection = ReplicatedStorage:WaitForChild("StartColorSelection")

local RequestColorSelection = ReplicatedStorage:WaitForChild("RequestColorSelection")

-- Minimal _L stub for ColorService initialization
local _L = {
    Shared = {
        Remotes = {
            -- Dummy implementations for required methods
            FireClient = function() end,
            OnServerInvoke = function() end,
            StartColorSelection = StartColorSelection,
            RequestColorSelection = RequestColorSelection,
        },
        Utils = {
            Warn = function(msg) warn(msg) end,
            DebugWT = function(msg) print(msg) end,
        }
    }
}```
#

the 2 lines at the top

#

when I require my module and initialise it I pass through the dependency table as the arguement

coarse fern
#

seems kind of like an architecture issue to me

#

i just wouldnt define my remote in a table in a module script

#

i would grab it directly

jaunty maple
#

that section of code is the serverscript

#

but it probably is an architecture issue

#

I didn't write the framework sighAang

#

just a commission

coarse fern
#

I'm just saying instead of this remote table u got going on I would do this

ReplicatedStorage:WaitForChild("RequestColorSelection"):FireAllClients()
jaunty maple
#

oh

coarse fern
#

garuntee that will fix ur problem

jaunty maple
#

leme try

#

I think it worked

coarse fern
#

sick

jaunty maple
#

new problem tho

gilded pollenBOT
#

studio** You are now Level 2! **studio

jaunty maple
#

kinda the same problem but in a different font

#

instead of it coming up as nil sometimes the event just isn't received by the client

#

somehow

#

I have prints to indicate if the event has been fired / if it has been received

#

sometimes it is both fired and then received

#

sometimes it is fired but never received

coarse fern
jaunty maple
#
game.ReplicatedStorage:WaitForChild("RequestColorSelection"):FireAllClients()
            print("RequestColorSelection event fired to all clients")```
#

I get output from this line so I'm assuming it is

#

I think it might have something to do with another error that pops up incidentally

#

but I didn't write the framework and its an error concerning that

#

and honestly I don't even want to touch it 😭

#

its this CorePackages.Workspace.Packages._Workspace.CoreScriptsProfiler.CoreScriptsProfiler.CoreScriptsProfilerTelemetry:170: attempt to index nil with 'Disconnect'

#

thanks for your help tho

coarse fern
#

but um

#

yeah this can be pretty complicated, if you want to message me in a DM i wont be as consistent in replies but I'll at least see your messages faster