#Attempting to call a table value?

1 messages · Page 1 of 1 (latest)

earnest parrot
#

I can't seem to understand. In the output, both "plr" and "skillValue.Value" return non-table numbers (playerUserId, 0). Why is it giving me this error on the last line (skillhandlerfunction)?


        local skillValue = Instance.new("IntValue")
        skillValue.Name = skill
        skillValue.Value = plrData.Skills[skill] or 0
        
        skillValue.Parent = skillsFolder

        if skillHandlers:FindFirstChild(skill) then

            local skillHandlerFunction = require(skillHandlers[skill])
            
            print(plr)
            print(skillValue.Value)
            skillHandlerFunction(plr, skillValue.Value)
        end
    end```
main flame
#

That’s wrong

earnest parrot
#

how so? Thank you btw

main flame
#

1 sec

#

local Players = game:GetService("Players")

for skill, _ in pairs(skillsModule) do
local skillValue = Instance.new("IntValue")
skillValue.Name = skill
skillValue.Value = plrData.Skills[skill] or 0
skillValue.Parent = skillsFolder

if skillHandlers:FindFirstChild(skill) then
    local skillHandlerFunction = require(skillHandlers[skill])

    -- Ensure 'plr' is a Player object
    local player = typeof(plr) == "number" and Players:GetPlayerByUserId(plr) or plr

    -- Optional: make sure 'player' is still valid
    if player and typeof(skillHandlerFunction) == "function" then
        print(player)
        print(skillValue.Value)
        skillHandlerFunction(player, skillValue.Value)
    else
        warn("Invalid player or skill handler for skill:", skill)
    end
end

end

#

@earnest parrot run that

#

See what error you get

#

If any

earnest parrot
#

ah. I think I didn't correctly assign the skill handler. Thank you!!