Attempt to call a nil value Camera TweenService

Hello DevForm member. I recently tried to modify one of my scripts to add a camera tween (knowing that it works without the tween). So, with the tween it returns an error Attempt to call a nil value
The Script :

Tween(workspace.Camera, 1.5, {CFrame = CurrCamera.CFrame})
Tween = function(Obj, Time, Settings)
	game:GetService("TweenService"):Create(Obj, TweenInfo.new(Time), Settings):Play()
end

image
Before you ask, I check the value of CurrCamera and this is a part so the problem is not coming from this

*If i do workspace.Camera.CFrame = CurrCamera.CFrame instead of tween its working

Use CurrentCamera. Not Camera. Also, you tried to call the function before it exists.

1 Like

The function “Tween” doesn’t exist yet when you’re trying to call it.
Try switching the order:

Tween = function(Obj, Time, Settings)
	game:GetService("TweenService"):Create(Obj, TweenInfo.new(Time), Settings):Play()
end
Tween(workspace.Camera, 1.5, {CFrame = CurrCamera.CFrame})

Well, i do that in another local script and its work (i think it’s not working when your adding local before)

Same error (with the function before)

local scripts are local they do not replicate to other clients

I found the problem, @treebee63 and @TypicalHB was half right. My function could be generated afterwards but it didn’t work because it was in a while true, which prevents the end of the code from being executed and therefore the function from existing

In fact I got the wrong script :sweat_smile:

1 Like