I got to make a MapVoter with the ViewportFrame, I want to view the map in the panel. As this twitt
Err:
10:19:34.472 - ServerScriptService.Scripts.VPR_GameScript:212: attempt to call a userdata value
Code: ``` Camera.CFrame = Cinematic.Elements.Cam1.CFrame
TweenService:Create(Camera, TweenInfo.new(Settings.VoteTime, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, true)
{CFrame = Cinematic.Elements.Cam2.CFrame}) -- line 212 ```
Why I can't set the CFrame of my camera?
```lua Camera.CFrame = Cinematic.Elements.Cam1.CFrame
TweenService:Create(Camera, TweenInfo.new(Settings.VoteTime, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, true)
{CFrame = Cinematic.Elements.Cam2.CFrame}) ```
Still don't see it?
lua
TweenService:Create(Camera, TweenInfo.new(Settings.VoteTime, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, true){CFrame = Cinematic.Elements.Cam2.CFrame})
You're trying to call the TweenInfo
object returned by TweenInfo.new
!
Remember that when you are calling a function, parentheses are optional if the first argument is a string or table literal, but it only works for one argument.
That is, the following examples are valid:
lua
fn"string";
fn{...}; --// some table with elements
But these are not:
```lua local s = "string"; local t = {...};
fn s fn t
fn"string", ...; --// some other arguments, but this is not valid ```
This is syntactic sugar
for a function call. Lua just thought that this was sugar for a function call.
lua
TweenService:Create(Camera, TweenInfo.new(Settings.VoteTime, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, true), {CFrame = Cinematic.Elements.Cam2.CFrame})
You forgot your comma to separate the arguments.
I personally like having the tweenInfo
in a variable, so it gets less messy. This also allows to reuse it with ease if you need to
Sort of like this:
```lua local info = TweenInfo.new(...); --// put stuff here local tween = TweenService:Create(Camera, info, {CFrame = Cinematic.Elements.Cam2.CFrame});
tween:Play(); --// play the tween ```