Getting Nil from a Passed Dictionary

I’m currently working on a Cutscene Module which can ease the work for Creating Cutscenes, but when I’m working on the CreateCutscene() function, I found out that the values passed from another ServerScript is turning into nil when I’m printing it out

I wonder if there is any misunderstanding about the Table Code.

Anyway, here is the ServerScript’s code :

local tweenInfo = {
	[1] = { -- I added [1] here cuz I've prepared multiple sections and part slots
	Position = CFrame.new(0,0,0),                -- End Position
	Duration = 2,                                -- Cutscene Duration
	EasingStyle = Enum.EasingStyle.Quad,         -- EasingStyle
	EasingDirection = Enum.EasingDirection.In    -- EasingDirection
	}
}

require(
	game.ServerStorage:WaitForChild("EasyCutscenes")
):CreateCutscene(tweenInfo) -- Passing the above Table to the Module Script

And here is the ModuleScript’s function :

function Cutscene:CreateCutscene(tweenInfo)
	print(tweenInfo[1]) -- This works as expected
	for i, v in tweenInfo do -- Looping through every Cutscene Sections, or Tables
		print(v[1], v[2], v[3]) -- Trying to print the values passed, but got nil
        --[[
           v[1] should be CFrame (EndPos) as expected,
           v[2] should be the duration,
           v[3] should be EasingStyle
        ]]
		local newTI = TweenInfo.new(
			v[2] or v.Duration,
			v[3] or v.EasingStyle,
			v[4] or v.EasingDirection
		)
	end
end

As you can see, I’m sending values from ServerScript to ModuleScript, but I got this when I’m printing out the Values (such as CFrame, duration and easingstyle)
Screenshot 2024-09-08 165558
Yes, they are all Nil for some reason,

But… why? Can anyone tell me? Any help is hightly apperciated!

Referencing it with numbers won’t work since v is a dictionary, not an array. When it’s a dictionary the “Position”,”Cframe” bla bla bla should be in square brackets like this. also

[1] = { -- I added [1] here cuz I've prepared multiple sections and part slots
	[“Position”]= CFrame.new(0,0,0),                -- End Position
	[“Duration”]= 2,                                -- Cutscene Duration
	[“EasingStyle”] = Enum.EasingStyle.Quad,         -- EasingStyle
	[“EasingDirection”] = Enum.EasingDirection.In    -- EasingDirection
	}

PS: Position should be a cframe since the value is a cframe :stuck_out_tongue:

1 Like

Oh it worked well, thanks for the help!

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