Hello,
I was trying to make a rig chat using a module script. However it seems to not be functioning when used inside the module script. All the prints work so it does reach the :chat() part.
How can i make :chat() work inside the module?
local enemies = {}
enemies.__index = enemies
function enemies:StartBehaviour()
local chatservice = game:GetService("Chat")
if not self.rig then warn("Missing rig!") return end
local number = math.random(1,2)
if number == 1 then
chatservice:Chat(self.rig.Head, "What a nice day.", Enum.ChatColor.Red)
print("Action1")
else
chatservice:Chat(self.rig.Head, "...", Enum.ChatColor.Red)
print("Action2")
end
end
function enemies:Create()
local chatservice = game:GetService("Chat")
local new = game.ReplicatedStorage:FindFirstChild(self.enemy)
if not new then
print("Comparison: Required "..self.enemy.." Got "..tostring(new))
return
end
local character = new:Clone()
self.rig = character
character.Parent = workspace
task.wait()
chatservice:Chat(self.rig:FindFirstChild("Head"), "Hello!", Enum.ChatColor.Red)
self:StartBehaviour()
end
function enemies.New(enemy:string)
local self = setmetatable({}, enemies)
self.enemy = enemy or "Noob"
self.rig = nil
return self
end
return enemies