-
What do you want to achieve?
Learn how to use this Metatable -
What is the issue?
Metatable keeps overwriting the other metatables -
What solutions have you tried so far?
I’ve looked into metatables deeper, but still can’t find anything relating to this.
I’m very new to metatables so any explanation or advice would be appreciated
local module = {}
module.__Index = module
--SERVICES
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--VARIABLES
module.InteractionsInGame = {
TeamCounter = {
Keybind = "E",
Time = 1,
ActionName = "Television",
Module = require(script.Parent.InteractionModules.TeamCounter),
Reload = false,
ReloadTime = 0
},
TeamCounter2 = { -- Added so i can see what's printing
Keybind = "E",
Time = 1,
ActionName = "Television",
Module = require(script.Parent.InteractionModules.TeamCounter),
Reload = false,
ReloadTime = 0
},
}
--MODULES
local Modules = {
["Core"] = {
ZonePlus = require(ReplicatedStorage.ReplicatedFramework.Packages._Index.ZonePlus)
}
}
--PRIVATE VARIABLES
--PRIVATE FUNCTIONS
--PUBLIC FUNCTIONS
function module.new(InteractionName, Zone, Keybind, ActionName, Time, InteractModule, Reload, ReloadTime)
if InteractionName and typeof(InteractionName) == "string" and Zone and Zone:IsA("Part") and Keybind and typeof(Keybind) == "string" then
if ActionName and typeof(ActionName) == "string" and Time and typeof(Time) == "number" and InteractModule then
local self = setmetatable(module, {})
self.Name = InteractionName
self.Zone = Modules.Core.ZonePlus.new(Zone)
self.ZonePart = Zone
self.Keybind = Keybind
self.ActionName = ActionName
self.Time = Time
self.InteractModule = InteractModule
self.ReloadTag = Reload
self.ReloadTagTime = ReloadTime
print(module)
return self
end
end
end
function module:RunInteraction(InteractModule, ZonePart)
InteractModule.RunInteraction(ZonePart)
end
function module:StopInteraction(InteractModule, ZonePart)
InteractModule.StopInteraction(ZonePart)
end
return module