You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I am really new to OOP, just discovered it today and I wanted to try and rescript some stuff to make my life easier. This code in particular is being used to script an NPC.
(This is probably just a huge beginner mistake, since I’m feeling like I’m missing something extremely obvious here.)
- What is the issue? Include screenshots / videos if possible!
Whenever I call :Move(), the script errors saying:
attempt to call missing method ‘Move’ of table
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried looking for other posts to see if theyve had the same issue but it seems that this is a small enough one that it just doesn’t get documented that frequently?
I also tried to double check and see if my format matched other people’s working code and I still came up empty.
-- Module Script
Npc = {}
Npc._index = Npc
function Npc.new(Goal, ColorFromRGB)
end
function Npc:Move(PositionInVector3)
local MoveValue = self:FindFirstChild("MovePosition")
MoveValue.Value = PositionInVector3
end
return Npc
-- Server Script
Npc = require(game.ReplicatedStorage.NpcModule)
local TempThing = Npc.new("red", Color3.fromRGB(219, 127, 127))
Npc.new("blue", Color3.fromRGB(128, 187, 219))
TempThing:Move(workspace.RedGoal.Position) -- this is the line that errors