Can i reference values from a dictonary inside the dictonary?

am trying to do this

local MovementDictionary = {
	["Sprinting"] = {
		
		Begin = function()
			if UIS:IsKeyDown(Enum.KeyCode.LeftShift) then

i’d like to replace Enum.KeyCode.Leftshift with a varaible from the dictonary

["Keybind"] = Enum.KeyCode.LeftShift

is this possible?

1 Like

Yes it is possible to do this, perhaps something like this:

local MovementDictionary = {
    Keybind = Enum.KeyCode.LeftShift, -- Define the keybind here
}

MovementDictionary["Sprinting"] = {
    Begin = function()
        if UIS:IsKeyDown(MovementDictionary.Keybind) then
            -- Sprinting code here
        end
    end
}

-- Usage
MovementDictionary["Sprinting"].Begin() -- Call the begin function

2 Likes

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