local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Powers = {}
Powers.__Index = Powers
function Powers.new(Name,Color,IsPassive,effect,key)
local self = setmetatable({}, Powers)
self.Name = Name or "Power"
self.Color = Color or Color3.new(1,1,1)
self.IsPassive = IsPassive
if self.IsPassive == false then
self.Key = key or Enum.KeyCode.RightControl
end
self.Effect = effect or "Pending"
self.Object = ReplicatedStorage.Orb:Clone()
self.Dependencies = "Pending"
self.Object.Outside.Color = self.Color
self.Object.Inside.Color = self.Color
self.Object.GetOrbData.OnInvoke = function()
return self
end
self.Object.ProximityPrompt.Triggered:Connect(function(Player)
print(getmetatable(self) , Powers)
print(self:Add(Player))
end)
return self
end
function Powers:Add(Player)
local playerModule = require(game.ServerStorage.PowerModules[Player.UserId])
local playerModule2 = require(Player.Character.PowersModule)
if not playerModule then error("PowerModule not found") end
playerModule.Powerlist[self.Key] = self.Effect
playerModule2.Powerlist[self.Key] = self.Effect
self.Object:Destroy()
return "Success"
end
return Powers
When self:Add() is called i get the attempt to call a nil value, despite it being right there.