Argument 1 missing or nil when tweening

I am trying to create a cutscene script where the camera pos tweens between 2 places, however, I am getting the error in the title on line 37:

tweenSerivce:Create(workspace.Camera, tweenInfo, {CFrame = folder.Points:FindFirstChild(tostring(curCam + 1).CFrame)}):Play()

If anyone can help me, I would be very grateful.

local folder = game.Workspace:WaitForChild("Cutscene Example") -- Change for each cutscene

local player
local activated = false

local cameras = 0

local tweenSerivce = game:GetService("TweenService")
local fadeInfo = TweenInfo.new(0.25, Enum.EasingStyle.Exponential)

local function fadeBlack()
	tweenSerivce:Create(player.PlayerGui.BlackScreen.Frame, fadeInfo, {BackgroundTransparency = 0}):Play()
end

local function unfadeBlack()
	tweenSerivce:Create(player.PlayerGui.BlackScreen.Frame, fadeInfo, {BackgroundTransparency = 1}):Play()
end

local function finish()
	unfadeBlack()
	wait(0.25)
	player.Character.Humanoid.WalkSpeed = 10
	workspace.Camera.CameraType = Enum.CameraType.Custom
end

local function main()
	local curCam = 0
	repeat
		cameras += -1
		curCam += 1
		local cam = folder.Points:FindFirstChild(tostring(curCam))
		workspace.Camera.CFrame = cam.CFrame
		unfadeBlack()

		if cam:FindFirstChild("TweenToNext").Value == true then
			local tweenInfo = TweenInfo.new(cam:FindFirstChild("Time").Value)
			tweenSerivce:Create(workspace.Camera, tweenInfo, {CFrame = folder.Points:FindFirstChild(tostring(curCam + 1).CFrame)}):Play()
		end

		if cam:FindFirstChild("Fade").Value == true then
			wait(cam:FindFirstChild("Time").Value - 0.25)
			fadeBlack()
			wait(0.25)
		else
			wait(cam:FindFirstChild("Time").Value)
		end

	until cameras <= 0
	finish()
end

local function setUp()
	player.Character.Humanoid.WalkSpeed = 0
	workspace.Camera.CameraType = Enum.CameraType.Scriptable
	fadeBlack()
	for _,part in folder.Points:GetChildren() do
		part.Transparency = 1
		part.CanCollide = false
		cameras += 1
	end
	wait(0.25)
	main()
end

local trigger = folder:WaitForChild("Activate")
trigger.Touched:Connect(function(part) --Start condition
	if not activated then
		if part.Parent:FindFirstChild("Humanoid") then
			player = game.Players:GetPlayerFromCharacter(part.Parent)
			activated = true
			setUp()
		end
	end
end)```

try game.Workspace.Camera, had this problem before and this fixed it

Unfortunately didn’t work.

(character limit)

Did you mean to use CurrentCamera?

As far as I am aware there are no differences between the 2 (may be wrong though)

I tried it anyway and still got the same error

I think workspace.Camera doesn’t carry over ingame, I might be wrong since I don’t do alot of this stuff with camera. Is this a local script or server?

It is a local script inside of StarterPlayerScripts

image
What is this? What does this line do?

This is the goals for the tween. It should tween the CFrame of the camera to the CFrame of the next camera.

Send me a screenshot of the folder and its descendants including curCam.

image

curCam is at line 30 and simply just increases by 1 for each loop

How much does curCam increase before the tween? :FindFirstChild() returns nil if there is no child found with that name.

curCam increases by 1 for each loop to represent which camera should be shown.

The code with the tween only runs when “TweenToNext” == true, which is only true for the camera named “2”.

Try this.

local folder = game.Workspace:WaitForChild("Cutscene Example") -- Change for each cutscene

local player
local activated = false

local cameras = 0

local tweenSerivce = game:GetService("TweenService")
local fadeInfo = TweenInfo.new(0.25, Enum.EasingStyle.Exponential)

local function fadeBlack()
	tweenSerivce:Create(player.PlayerGui.BlackScreen.Frame, fadeInfo, {BackgroundTransparency = 0}):Play()
end

local function unfadeBlack()
	tweenSerivce:Create(player.PlayerGui.BlackScreen.Frame, fadeInfo, {BackgroundTransparency = 1}):Play()
end

local function finish()
	unfadeBlack()
	wait(0.25)
	player.Character.Humanoid.WalkSpeed = 10
	workspace.Camera.CameraType = Enum.CameraType.Custom
end

local function main()
	local curCam = 0
	repeat
		cameras += -1
		curCam += 1
		local cam = folder.Points:FindFirstChild(tostring(curCam))
		workspace.Camera.CFrame = cam.CFrame
		unfadeBlack()

		if cam:FindFirstChild("TweenToNext").Value == true then
			local tweenInfo = TweenInfo.new(cam:FindFirstChild("Time").Value)
			tweenSerivce:Create(workspace.Camera, tweenInfo, {CFrame = folder.Points:FindFirstChild(tostring(curCam + 1).CFrame)}):Play()
		end

		if cam:FindFirstChild("Fade").Value == true then
			wait(cam:FindFirstChild("Time").Value - 0.25)
			fadeBlack()
			wait(0.25)
		else
			wait(cam:FindFirstChild("Time").Value)
		end

	until cameras <= 0 or curCam >= 2
	finish()
end

local function setUp()
	player.Character.Humanoid.WalkSpeed = 0
	workspace.Camera.CameraType = Enum.CameraType.Scriptable
	fadeBlack()
	for _,part in folder.Points:GetChildren() do
		part.Transparency = 1
		part.CanCollide = false
		cameras += 1
	end
	wait(0.25)
	main()
end

local trigger = folder:WaitForChild("Activate")
trigger.Touched:Connect(function(part) --Start condition
	if not activated then
		if part.Parent:FindFirstChild("Humanoid") then
			player = game.Players:GetPlayerFromCharacter(part.Parent)
			activated = true
			setUp()
		end
	end
end)```

Still getting the same issue.

(char limit)

You put the bracket after the .CFrame to close the :FindFirstChild() which I think is giving you the error so you just need to change line 37 to

tweenSerivce:Create(workspace.Camera, tweenInfo, {CFrame = folder.Points:FindFirstChild(tostring(curCam + 1)).CFrame}):Play()

Edit: I may be wrong but i hope this helps

1 Like

I am not sure how to fix this, then. Sorry.

OML I FEEL SO DUMB TY VERY MUCH.

thanks everyone for helping

1 Like

We all do it is always the simple mistakes we miss, but its always great to have someone else look over your code as you may not see the mistake.

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