Types and Whatever idk

I’m making a state system for my game with addable and removeable states. I want to know which states are available using type.

type States = "Dead" | "IFrames" | "Stunned" | "Attacking" | "Parrying" | "Blocking" | "Any"

You can see there’s already 7 basic ones. I want to externally add another string onto this line so when I call on my function:

function module:SetState(State : States, Value : true | false | "Any", Time, bypass: boolean)
	if self.CurrentState.Name == "Dead" and not bypass then return end;
	
	if self.PriorityTable[self.CurrentState.Name] > self.PriorityTable[State] then
		self.CurrentState.Name = State
		self.CurrentState.Value = Value
		
		self.States[State] = true
		self.Signal:Fire("States", "CurrentState", State, Value, Time)
	end
	
	if Time == nil or Time == 0 then return end;
	
	self.Timers[State.." Timer"] = TimerModule.new(State .. " Timer", Time, function()
		
		warn("State has finished, attempting to return the current state to Idle.")	
		self:UpdateState("Idle", true, 0)
		self.States[State] = false
		
	end)
	
	self.Timers[State.." Timer"]:startTimer(Time)
end

It’ll do the little thing where it tells you what’s available.

image

just wanna know if that’s impossible and im overthinking it lol :grimacing::pray:

2 Likes

DO NOT COOK LIKE THAT AGAIN PLEASE!

Did you mean allowing to add any other string? Just put | string
I probably haven’t understood you, but if you meant auto-completion, then it’s probably a bug.

Although it would be neat for Luau to support this, the Luau language uses static typing for type checking and autocomplete. Therefore, you wouldn’t be able to have autocomplete for an external type which is referenced elsewhere.

Read more about this here: Type checking | Documentation - Roblox Creator Hub