Heya Everyone!!
This is a simple follow up from a previous post I’ve made here. I didn’t want to drag it from there so I’ll do a follow up.
For anyone wondering from the previous post, I was trying to access self.Robotxian from the base class, that being ROBOTXIAN_MAIN. Luckily, I was able to get an answer telling me that I wasn’t actually returning self and thus being unable to use it. The fix was simply just adding self to the table inside of the constructor I am using.
The issue now is that I’m trying to use classesSelf (Check the post to what I’m talking about) to use functions inside of the subclass (Which is BUILDER_CLASS) alongside trying to use classesSelf inside of said functions (Such as a Build function.)
Keep in mind that I’m still new to OOP alongside making this post in 11 PM, so I’m pretty sleepy.
ROBOTXIAN_MAIN (Just in case anyone needs it)
--[[INFO]]--
--//ROBOTXIAN_MAIN is the base class of both the 'Builder' and 'Fighter' class.
--//This contains essential functions for both class to work such as pathfinding or even creating Robotxians in the first place.
--[[SERVICES]]--
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Debris = game:GetService("Debris")
--[[FOLDERS]]--
local Events_Folder = ReplicatedStorage:WaitForChild("EVENTS")
local Preset_Player_Models_Folder = ServerStorage:WaitForChild("PRESET_PLAYER_MODELS")
--[[MODULE]]--
local ROBOTXIAN_MAIN_FUNCTION = {}
ROBOTXIAN_MAIN_FUNCTION.__index = ROBOTXIAN_MAIN_FUNCTION
--//Spawning and despawning the robotxian.
function ROBOTXIAN_MAIN_FUNCTION.CreateNewRobotxian()
local self = {}
--//Just to be safe, I'd assume this is where I'd spawn them in.
self.Robotxian = ServerStorage.PRESET_PLAYER_MODELS.R6:Clone()
self.Robotxian.Parent = game.Workspace
return setmetatable({self = self}, ROBOTXIAN_MAIN_FUNCTION)
end
--//Pathfinding
function ROBOTXIAN_MAIN_FUNCTION:Pathfind()
--//TBA
end
return ROBOTXIAN_MAIN_FUNCTION
BUILDER_CLASS
--[[INFO]]--
--//The 'Builder' class is one of the two classes a robotxian can have.
--//As the name says, robotxians with the class will be able to spawn in parts and modify them to their liking.
--//Additionally, robotxians will also be able to apply both decals and a handful of special effects such as Fire or Sparkles.
--//Generally, robotxians with the class will just spawn in random parts but will occasionally start building actual stuff such as a small house or a poorly made robloxian.
--[[BASE CLASS]]--
local ROBOTXIAN_MAIN = require(script.Parent.Parent.ROBOTXIAN_MAIN)
--[[MODULE]]--
local BUILDER_CLASS_MODULE = setmetatable({}, {__index = ROBOTXIAN_MAIN})
BUILDER_CLASS_MODULE.__index = BUILDER_CLASS_MODULE
function BUILDER_CLASS_MODULE.CreateNewBuilderRobotxian()
local Robotxian = ROBOTXIAN_MAIN.CreateNewRobotxian()
local RobotxianSelf = Robotxian.self
end
function BUILDER_CLASS_MODULE:Build()
--//Trying to use self here.
end
return BUILDER_CLASS_MODULE