Input
local Ghost = {}
Ghost.__index = Ghost
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local function SetAttributes()
-- later
end
function Ghost.new()
SetAttributes()
self = setmetatable({}, Ghost)
self.Body = script:WaitForChild("Ghost"):Clone()--to become something else
self.Body.Parent = ReplicatedStorage.ClonedGhosts
print(self.Body)
self.Name = self.Body:GetAttribute("Name")
self.Type = self.Body:GetAttribute("Type")
self.Difficulty = self.Body:GetAttribute("Difficulty")
self.Room = self.Body:GetAttribute("Room")
self.RoomName = self.Body:GetAttribute("RoomName")
self.Body.Position = self.Room
print(self)
return self
end
function Ghost:Hunt()
print(self)
print(self.Body)
self.Body.Parent = workspace
return self
end
function Ghost:EndHunt()
self.Body.Parent = script
return self
end
return Ghost
Output
For some weird, odd reason the self variable gets overwritten with the class functions, and I have no idea why. It’s nothing to do with attributes, those are set ahead of time.