I have two OOP scripts that work together but the combo object is always printing nil. I don’t understand why though. Thanks for any help.
-- Combo Handling
-- This is inside a player OOP module and self["userid"] is printing correctly
local comboObject = comboModule.getComboMeter(self["UserId"])
print(self["UserId"])
print("Hello")
print(comboObject)
comboObject:Update(1)
-- Combo Module
local ComboMeter = {}
ComboMeter.__index = ComboMeter
local comboTable = {}
function ComboMeter.new(textLabel, plr)
local newComboObject = setmetatable({
ComboNumber = 0,
Label = textLabel,
Color = Color3.new(1,1,1)
}, ComboMeter)
comboTable[tostring(plr.UserId)] = newComboObject
task.wait(1)
print(comboTable)
return newComboObject
end
function ComboMeter.getComboMeter(plrId)
print(comboTable)
return comboTable[tostring(plrId)]
end
function ComboMeter:Update(amount)
self["ComboNumber"] += amount
self["Label"].Text = tostring(self["ComboNumber"])
end
return ComboMeter
Output{
20:09:02.898 Hello world! - Server - EnemyDamageHandler:1
20:09:03.020 ▼ {
[“2002444799”] = ▼ {
[“Ability”] = “Hacker”,
[“Active”] = false,
[“BasicAttack”] = “function”,
[“BasicHits”] = 0,
[“Grapple”] = “function”,
[“LastAttackTime”] = 0,
[“Name”] = “Loading…”,
[“SetUp”] = “function”
},
[“__index”] = “*** cycle table reference detected ***”,
[“getPlayerProfile”] = “function”,
[“new”] = “function”
} - Server - Player Setup:29
20:09:03.075 Initial Character Loaded for speedb0y1290 - Server - Player Setup:59
20:09:03.075 Character: speedb0y1290 - Server - Player Setup:60
20:09:03.077 ▼ {
[“Ability”] = “Hacker”,
[“Active”] = false,
[“BasicAttack”] = “function”,
[“BasicHits”] = 0,
[“Character”] = speedb0y1290,
[“Grapple”] = “function”,
[“LastAttackTime”] = 0,
[“Name”] = “speedb0y1290”,
[“SetUp”] = “function”,
[“UserId”] = 2002444799
} - Server - Player Joined:9
20:09:03.725 Animation Spoofer cannot run while game is running - Server
20:09:04.120 Animation Spoofer cannot run while game is running - Client
20:09:05.410 Failed to load sound rbxassetid://390457804: Requested asset is archived - Studio
20:09:05.692 ▼ {
[“2002444799”] = ▼ {
[“Color”] = 1, 1, 1,
[“ComboNumber”] = 0,
[“Label”] = TextLabel
}
} - Client - Combos:21
20:09:07.122 reset cooldown - Server - Player Setup:85
20:09:07.123 1 - Server - Player Setup:95
20:09:07.124 {} - Server - Combos:26
20:09:07.125 2002444799 - Server - Player Setup:109
20:09:07.125 Hello - Server - Player Setup:110
20:09:07.125 nil - Server - Player Setup:111
20:09:07.125 ReplicatedStorage.Player Setup:112: attempt to index nil with ‘Update’ - Server - Player Setup:112
20:09:07.126 Stack Begin - Studio
20:09:07.126 Script ‘ReplicatedStorage.Player Setup’, Line 112 - function BasicAttack - Studio - Player Setup:112
20:09:07.126 Script ‘Workspace.speedb0y1290.Script’, Line 10 - Studio - Script:10
20:09:07.126 Stack End - Studio
20:09:07.922 2 - Server - Player Setup:95
20:09:07.922 {} - Server - Combos:26
20:09:07.923 2002444799 - Server - Player Setup:109
20:09:07.923 Hello - Server - Player Setup:110
20:09:07.923 nil - Server - Player Setup:111
20:09:07.923 ReplicatedStorage.Player Setup:112: attempt to index nil with ‘Update’ - Server - Player Setup:112
20:09:07.924 Stack Begin - Studio
20:09:07.925 Script ‘ReplicatedStorage.Player Setup’, Line 112 - function BasicAttack - Studio - Player Setup:112
20:09:07.925 Script ‘Workspace.speedb0y1290.Script’, Line 10 - Studio - Script:10
20:09:07.925 Stack End - Studio
20:09:08.939 on long cooldown - Server - Player Setup:93
20:09:08.939 0 - Server - Player Setup:95
20:09:08.939 {} - Server - Combos:26
20:09:08.939 2002444799 - Server - Player Setup:109
20:09:08.940 Hello - Server - Player Setup:110
20:09:08.940 nil - Server - Player Setup:111
20:09:08.940 ReplicatedStorage.Player Setup:112: attempt to index nil with ‘Update’ - Server - Player Setup:112
20:09:08.940 Stack Begin - Studio
20:09:08.940 Script ‘ReplicatedStorage.Player Setup’, Line 112 - function BasicAttack - Studio - Player Setup:112
20:09:08.940 Script ‘Workspace.speedb0y1290.Script’, Line 10 - Studio - Script:10
}