How can I have "enums" for guns to set their state?

is something like this possible?
something you’d see in PHP

a property that’s an enum
ugh idk how to explain it

but basically, i want to use custom enums to change gun states, are custom enums possible?

I’m not sure if this is the best approach, but you could have a modulescript with something like this

return{
	State1 = "State1",
	State2 = "State2",
	State3 = "State3"
	-- and so on
}

then you can reference those in whatever scripts you need, something such as

local gunStates = require(game.ReplicatedStorage.GunStates)
gun.State = gunStates.State1

or something like

local gunStates = require(game.ReplicatedStorage.GunStates)
if gun.State == gunStates.State1 then
	-- blah blah
end

there may be better ways to do this, but this has always been my approach and it works pretty well

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.