#cant call method with oop

1 messages · Page 1 of 1 (latest)

hot pulsar
#
--still incomplete, waiting on models

local RunService = game:GetService("RunService")
local Camera = workspace.CurrentCamera

local ToolHandler = {}
ToolHandler.__index = ToolHandler

local Updater

function ToolHandler.Equip(Model : Model, Offset : CFrame, Angle : CFrame)
    local prop = {}
    prop.Model = Model
    
    Updater = RunService.RenderStepped:Connect(function(delta) --init
        Model:PivotTo(Camera.CFrame * Offset * Angle)
    end)
    
    return setmetatable(prop, ToolHandler)
end

function ToolHandler:Drop()
    print("Dropped tool")
end

return ToolHandler
#

idk what im doing wrong here

hollow bloom
#

you can

#

you just dont call it

#

show the script where you require it from

#

@hot pulsar

hot pulsar
#

damn, uhh this is alward, im outside 💀

hot pulsar
#

despite me already setting a metatable and __index metamethod

hollow bloom
#

well

#

I tried it and it works

#

local RunService = game:GetService("RunService")
local Camera = workspace.CurrentCamera

local ToolHandler = {}
ToolHandler.__index = ToolHandler

local Updater

function ToolHandler.Equip(Model : Model, Offset : CFrame, Angle : CFrame)
    local prop = {}
    prop.Model = Model

    Updater = RunService.RenderStepped:Connect(function(delta) --init
        Model:PivotTo(Camera.CFrame * Offset * Angle)
    end)

    return setmetatable(prop, ToolHandler)
end

function ToolHandler:Drop()
    print("Dropped tool")
end

return ToolHandler```
#

your module

#


d:Drop()


#

my local

#

and it prints "Dropped tool"

hot pulsar
#

my dawg

#

its object oriented

#

your suppost to use the ToolHandler.Equip first

#

then on whatever that function returns, use the method :Drop

hollow bloom
#

forgot

#

idk what ur problem is

#

u js said u cant call it

hot pulsar
#

heres the script calling the method

#

theres a ToolHeld:Init function yet that works fine

#

everything works if i test it here for some reason

#

alr i fixed it

#

forgot to return the properties table in the new script lol