Module does not autocomplete

Hello! So currently I was working on a module. However for some reason on the other script the autocomplete does not work… Can I ask why?

export type Self = {
	Character: Model?,
	Enabled: boolean?,
	Direction: Vector3?,
	Player: Player?,
	Move: (self: Self, direction: Vector3) -> (),
	SetEnabled: (self: Self, bool: boolean) -> (),
	New: (char: Model) -> Self
}

local CAS = game:GetService("ContextActionService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local module = {} :: Self
module.__index = module

function module.New(char: Model) 
	local self = setmetatable({}, module)
	self.Character = char :: Model
	self.Enabled = false :: boolean
	self.Direction = Vector3.new(0, 0, 0) :: Vector3
	self.SideDirection = Vector3.new(0,0,0) :: Vector3
	return self
end

function module:SideMove(direction: Vector3)

end

function module:Move(direction: Vector3)

end

function module:GetInformations()

end

function module:SetEnabled(bool: boolean)

end

function module:EnableSideMovement()

end

return module

for some reason, if I will type “characterModule:SetEnabled(true)”, the “SetEnable” thing on autocomplete does not come up, is there any fix on that?

For example:

local characterModule = require(game.Players.LocalPlayer.PlayerScripts.Core.PlayerMovementHandler).New(game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait())

task.wait(2.5)

characterModule:EnableSideMovement()
characterModule:Move(Vector3.new(0, 0, -1))
characterModule:SetEnabled(true)
print(characterModule:GetInformations())

task.wait(5)
characterModule:SetEnabled(false)

image

1 Like

This should be some kind of bug, try restarting studio or re-opening your script again.

Oh! I just remebered, you using the functions outside the new() function your made. So all the module:something_here() functions should be inside that new() fucntion.

Alright, I tried to restart the studio and placed all the outside functions inside, however the autocomplete is still not working :frowning:

also please ignore the second script and the type of formating it, it is a test script

That’s odd, this module I made autocompletes. (its returns self)

Screenshot 2024-08-23 163534
Image (1)

This also works, try formatting your code like this.

Image

roblox is very specific with auto completing custom types and sometimes doesn’t work even if you’re doing it properly. To fix this you can easily just assign the type manually

local module = require(module)
local class = module.new() :: module.Self

since you are exporting the type, you can assign it to variables in other scripts requiring that module

Ohhh, I found the problem, your type checking a returning self, so nothing popping up.

Change this

local module = {} :: Self

To this

local module = {}

Well, I tried to do it, still does not autocomplete. I tried to format my script a bit better, still doesnt work.

Already tried, does not change anything

Did you do what I said?

Well in the commandbar, I can see that too, although in the actual script it does not work

Screenshot 2024-08-23 165644
It must be a bug, did you exactly copy what i did in the previous script?

1 Like

Yes I did, I don’t know whats the problem

Can you send over a screenshot so i can verify?

As I said, I got it in the command prompt though

You never put the index

module.__index = module

Yes I accidentaly removed that, I put it back, still does not change