Rajin98
(Rajin98)
August 23, 2024, 2:23pm
#1
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)
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.
Rajin98
(Rajin98)
August 23, 2024, 2:29pm
#4
Alright, I tried to restart the studio and placed all the outside functions inside, however the autocomplete is still not working
Rajin98
(Rajin98)
August 23, 2024, 2:35pm
#5
Rajin98:
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
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)
This also works, try formatting your code like this.
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 = {}
Rajin98
(Rajin98)
August 23, 2024, 2:49pm
#10
Well, I tried to do it, still does not autocomplete. I tried to format my script a bit better, still doesnt work.
Rajin98
(Rajin98)
August 23, 2024, 2:49pm
#11
Already tried, does not change anything
Rajin98
(Rajin98)
August 23, 2024, 2:54pm
#13
Well in the commandbar, I can see that too, although in the actual script it does not work
It must be a bug, did you exactly copy what i did in the previous script?
1 Like
Rajin98
(Rajin98)
August 23, 2024, 2:58pm
#15
Yes I did, I don’t know whats the problem
Can you send over a screenshot so i can verify?
Rajin98
(Rajin98)
August 23, 2024, 3:01pm
#18
As I said, I got it in the command prompt though
Rajin98
(Rajin98)
August 23, 2024, 3:04pm
#20
Yes I accidentaly removed that, I put it back, still does not change