Module cannot find instances

Hello! I was making a cutscene script for one of my games when the module responsible for the cutscene failed, and I found out it cannot find any instance.

Heres the module: It is placed in ServerScriptService and is runned via Server Script.

local module = {}
local cutsceneStuff = game.ReplicatedStorage.CutsceneStuff
local remotes = game.ReplicatedStorage.Remotes

function module.loadCutscene(player: Player, map)
	print(map:GetDescendants())
	cutsceneStuff.BlackScreen:FireAllClients(TweenInfo.new(0.001), 0)
	player.Character:PivotTo(map.Cutscene.PlayerSpawn.CFrame)
	cutsceneStuff.StartCutscene:FireAllClients(map.Cutscene.CamParts:WaitForChild("CamPart1"))
	wait(.5)
	cutsceneStuff.BlackScreen:FireAllClients(TweenInfo.new(1, Enum.EasingStyle.Sine), 1)
	cutsceneStuff.SetMusic:FireAllClients(script:WaitForChild("Suspense").SoundId)
	wait(1)
	remotes.Dialog:FireAllClients(player.DisplayName, "I'm out of fuel and I got the signal here.", Color3.fromRGB(211, 211, 211), 0.03, 3)
	wait(3.1)
	remotes.Dialog:FireAllClients(player.DisplayName, "I hope I find that person and a gas can here.", Color3.fromRGB(211, 211, 211), 0.03, 2)
	wait(2.1)
	remotes.Dialog:FireAllClients(player.DisplayName, "But how am I supposed to enter? Isn't that trespassing?", Color3.fromRGB(211, 211, 211), 0.03, 3)
	cutsceneStuff.MoveCamera:FireAllClients(map.Cutscene.CamParts:WaitForChild("CamPart2"), TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut))
	wait(3.1)
	cutsceneStuff.MoveCamera:FireAllClients(map.Cutscene.CamParts:WaitForChild("CamPart3"), TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut))
	wait(2)
	remotes.Dialog:FireAllClients(player.DisplayName, "Oh. I can go through the sewers. I hope it doesnt turn out bad.", Color3.fromRGB(211, 211, 211), 0.03, 1)
	wait(1.1)
	remotes.Dialog:FireAllClients(player.DisplayName, "Here we go.", Color3.fromRGB(211, 211, 211), 0.03, 1)
	cutsceneStuff.SetFOV:FireAllClients(80, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut))
	wait(1.1)
	cutsceneStuff.BlackScreen:FireAllClients(TweenInfo.new(1, Enum.EasingStyle.Sine), 0)
	cutsceneStuff.EndCutscene:FireAllClients()
end

return module

I would appreciate your help! Feel free to ask questions, I will try my best to reply.

And also, it can still detect the remotes, it just does not detect instances inside map variable.

1 Like

Is there like an error message anywhere? are you passing the arguments correctly?

1 Like

it always says Argument is missing or nil but I passed the arguments correctly.

The errors come from the client script responsible for the remotes but i could not find any errors in it.

what’s the error on the client script

the error comes from alot of lines, I will show each:

Line 15:
local newTween = ts:Create(cam, tweenInfo, {CFrame = camPart.CFrame})

Line 11:
cam.CFrame = camPart.CFrame

it comes from those lines, and also cam is workspace.CurrentCamera and ts is TweenService

ok but what exactly is the error, I can’t work out what’s wrong without knowing why it’s happening

it says Argument 2 missing or nil on line 15

it says “Players.cherrypathy.PlayerGui.CutsceneHandler:11: attempt to index nil with ‘CFrame’” on line 11

Should execute this smoothly ig?

local module = {}
local cutsceneStuff = game.ReplicatedStorage.CutsceneStuff
local remotes = game.ReplicatedStorage.Remotes

function module.loadCutscene(player: Player, map)
    cutsceneStuff.BlackScreen:FireAllClients(TweenInfo.new(0.001), 0)
    
    player.Character:PivotTo(map.Cutscene.PlayerSpawn.CFrame)
    
    cutsceneStuff.StartCutscene:FireAllClients(map.Cutscene.CamParts:WaitForChild("CamPart1"))
    wait(0.5)
    
    cutsceneStuff.BlackScreen:FireAllClients(TweenInfo.new(1, Enum.EasingStyle.Sine), 1)
    
    cutsceneStuff.SetMusic:FireAllClients(script:WaitForChild("Suspense").SoundId)
    wait(1)
    
    remotes.Dialog:FireAllClients(player.DisplayName, "I'm out of fuel and I got the signal here.", Color3.fromRGB(211, 211, 211), 0.03, 3)
    wait(3.1)
    
    remotes.Dialog:FireAllClients(player.DisplayName, "I hope I find that person and a gas can here.", Color3.fromRGB(211, 211, 211), 0.03, 2)
    wait(2.1)
    
    remotes.Dialog:FireAllClients(player.DisplayName, "But how am I supposed to enter? Isn't that trespassing?", Color3.fromRGB(211, 211, 211), 0.03, 3)
    
    cutsceneStuff.MoveCamera:FireAllClients(map.Cutscene.CamParts:WaitForChild("CamPart2"), TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut))
    wait(3.1)
    
    cutsceneStuff.MoveCamera:FireAllClients(map.Cutscene.CamParts:WaitForChild("CamPart3"), TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut))
    wait(2)
    
    remotes.Dialog:FireAllClients(player.DisplayName, "Oh. I can go through the sewers. I hope it doesnt turn out bad.", Color3.fromRGB(211, 211, 211), 0.03, 1)
    wait(1.1)
    
    remotes.Dialog:FireAllClients(player.DisplayName, "Here we go.", Color3.fromRGB(211, 211, 211), 0.03, 1)
    
    cutsceneStuff.SetFOV:FireAllClients(80, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut))
    wait(1.1)
    
    cutsceneStuff.BlackScreen:FireAllClients(TweenInfo.new(1, Enum.EasingStyle.Sine), 0)
    
    cutsceneStuff.EndCutscene:FireAllClients()
end

return module

so camPart is never being passed, is this in the onclientevent?

yes its in the onclientevent. but i pass the part argument as an instance there

I tried it and it did not change anything

Hmm try this?

local module = {}
local cutsceneStuff = game.ReplicatedStorage.CutsceneStuff
local remotes = game.ReplicatedStorage.Remotes

function module.loadCutscene(player: Player, map)
    if not map or not map.Cutscene or not map.Cutscene.CamParts then
        print("Error: Missing map or map.Cutscene or map.Cutscene.CamParts")
        return
    end

    cutsceneStuff.BlackScreen:FireAllClients(TweenInfo.new(0.001), 0)
    
    if map.Cutscene.PlayerSpawn and map.Cutscene.PlayerSpawn.CFrame then
        player.Character:PivotTo(map.Cutscene.PlayerSpawn.CFrame)
    else
        print("map.Cutscene.PlayerSpawn or CFrame wasnt found")
    end
    
    local camPart1 = map.Cutscene.CamParts:FindFirstChild("CamPart1")
    if camPart1 then
        cutsceneStuff.StartCutscene:FireAllClients(camPart1)
    else
        print("campart1 not found")
    end

    cutsceneStuff.BlackScreen:FireAllClients(TweenInfo.new(1, Enum.EasingStyle.Sine), 1)
    
    local suspenseSound = script:FindFirstChild("Suspense")
    if suspenseSound and suspenseSound:IsA("Sound") then
        cutsceneStuff.SetMusic:FireAllClients(suspenseSound.SoundId)
    else
        print("Error: Suspense sound not found or is not a Sound instance")
    end

    if player.DisplayName then
        remotes.Dialog:FireAllClients(player.DisplayName, "I'm out of fuel and I got the signal here.", Color3.fromRGB(211, 211, 211), 0.03, 3)
    else
        print("player does not have displayname property")
    end

    local camPart2 = map.Cutscene.CamParts:FindFirstChild("CamPart2")
    if camPart2 then
        cutsceneStuff.MoveCamera:FireAllClients(camPart2, TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut))
    else
        print("cam2 not found")
    end

    local cutsceneHandler = player:FindFirstChildOfClass("PlayerGui"):FindFirstChild("CutsceneHandler")
    if cutsceneHandler then
        cutsceneStuff.SetFOV:FireAllClients(80, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut))
    else
        print("cutsecene not found")
    end

    cutsceneStuff.BlackScreen:FireAllClients(TweenInfo.new(1, Enum.EasingStyle.Sine), 0)
    cutsceneStuff.EndCutscene:FireAllClients()
end

return module

image
now it says this. heres the server script if you want it:

local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")

local cutsceneModule = require(script.CutsceneModule)

local chapter = 1
local map = "AbandonedFactory"

Players.PlayerAdded:Connect(function(player)
	local teleportData = TeleportService:GetLocalPlayerTeleportData()
	if teleportData then
		local chapterData = teleportData.Chapter
		local mapData = teleportData.Map

		if chapterData and mapData then
			chapter = chapterData
			map = mapData
		else
			-- add functions soon
		end
	else

	end
	player.CharacterAdded:Wait()
	cutsceneModule.loadCutscene(player, workspace.Map)
end)
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local cutsceneModule = require(script.CutsceneModule)

local chapter = 1
local map = "AbandonedFactory"

Players.PlayerAdded:Connect(function(player)
    local teleportData = TeleportService:GetLocalPlayerTeleportData()
    if teleportData then
        local chapterData = teleportData.Chapter
        local mapData = teleportData.Map

        if chapterData and mapData then
            chapter = chapterData
            map = mapData
        else
            warn("error missing chapter data or map data in tpdata")
        end
    else
        warn("error no tp data found for player")
    end

    player.CharacterAdded:Wait()
    local mapInstance = workspace:FindFirstChild(map)
    if mapInstance then
        cutsceneModule.loadCutscene(player, mapInstance)
    else
        warn("map not found in workspace.")
    end
end)

still the same error, Module code did not return exactly one value (Line 3 this time)

It’s always great to add error handling incase for debugging

local module = {}
local cutsceneStuff = game.ReplicatedStorage.CutsceneStuff
local remotes = game.ReplicatedStorage.Remotes

function module.loadCutscene(player, map)
    if not map or not map.Cutscene or not map.Cutscene.CamParts then
        warn("Warning: Missing map or map.Cutscene or map.Cutscene.CamParts")
    end

    cutsceneStuff.BlackScreen:FireAllClients(TweenInfo.new(0.001), 0)

    if map.Cutscene.PlayerSpawn and map.Cutscene.PlayerSpawn.CFrame then
        player.Character:SetPrimaryPartCFrame(map.Cutscene.PlayerSpawn.CFrame)
    else
        -- Example: Default spawn behavior (teleport player to a fallback spawn point)
        -- player:LoadCharacter()
    end

    local camPart1 = map.Cutscene.CamParts:FindFirstChild("CamPart1")
    if camPart1 then
        cutsceneStuff.StartCutscene:FireAllClients(camPart1)
    end

    cutsceneStuff.BlackScreen:FireAllClients(TweenInfo.new(1, Enum.EasingStyle.Sine), 1)

    local suspenseSound = game.Workspace:FindFirstChild("Suspense")
    if suspenseSound and suspenseSound:IsA("Sound") then
        cutsceneStuff.SetMusic:FireAllClients(suspenseSound.SoundId)
    end

    remotes.Dialog:FireAllClients(player.DisplayName or "UnknownPlayer", "I'm out of fuel and I got the signal here.", Color3.fromRGB(211, 211, 211), 0.03, 3)

    local camPart2 = map.Cutscene.CamParts:FindFirstChild("CamPart2")
    if camPart2 then
        cutsceneStuff.MoveCamera:FireAllClients(camPart2, TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut))
    end

    local cutsceneHandler = player:FindFirstChildOfClass("PlayerGui") and player.PlayerGui:FindFirstChild("CutsceneHandler")
    if cutsceneHandler then
        cutsceneStuff.SetFOV:FireAllClients(80, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut))
    end

    cutsceneStuff.BlackScreen:FireAllClients(TweenInfo.new(1, Enum.EasingStyle.Sine), 0)
    cutsceneStuff.EndCutscene:FireAllClients()
end

return module

the module is fixed now but it says the map is not in the workspace even though it is

Thats good to hear now we gotta fix that.

Which script outputs that if you dont mind me asking?