Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't my camera interpolation script moving anywhere?

Asked by 7 years ago
Edited 7 years ago

I'm working on a simple plugin that lets you easily record establishing shots in studio. The basic premise is that you can set an interpolation end point and an interpolation length. However, even though I'm not getting any errors and I'm absolutely sure that my script is running all the way through, the camera itself never moves. Any help would be appreciated. Thanks!

NOTE: I've tried this in both a regular script and a local script, both yield the same result.

--user data
local camera=   Workspace:WaitForChild("Camera")

--meta variables (All of these get a value from other parts in the script)
local isOn =true
local length=   1
local endPos =CFrame.new(0,0,0)
local isRunning =false

function interpolate()
    if isOn and length and endPos and not isRunning then
        isRunning=true
        if not camera then
            camera=Workspace:WaitForChild("Camera")
        end
        camera.CameraType=Enum.CameraType.Scriptable
        camera:Interpolate(endPos,endPos*CFrame.new(0,0,20),length)
        wait(length)
        if isRunning then
            camera.CameraType=Enum.CameraType.Fixed
            isRunning=false
        end
    end
end

runButton.MouseButton1Click:connect(interpolate)
0
Of course it can't run. Your if statement to run does not meet the standards. FiredDusk 1466 — 7y

1 answer

Log in to vote
0
Answered by
FiredDusk 1466 Moderation Voter
7 years ago

I am not the best scripter and not fully sure about if this would work but, I will give this answer a shot. I have made some comments below.

--user data
local camera=   workspace:WaitForChild("Camera")

--meta variables
local isOn= true
local length=   1
local endPos= 
local isRunning= false

function interpolate()
    if isOn and not isRunning then -- I don't think you could check for the others, so I left these in.
        isRunning=true
        if not camera then
            camera=workspace:WaitForChild("Camera") -- Would be best to make the "W" on workspace a lower case.
        end
        camera.CameraType=Enum.CameraType.Scriptable
        camera:Interpolate(endPos,endPos*CFrame.new(0,0,20),length)
        wait(length)
        if isRunning then
            camera.CameraType=Enum.CameraType.Fixed
            isRunning=false
        end
    end
end

runButton.MouseButton1Click:connect(interpolate)

If this helped, please accept my answer :)

0
Replace endPos = with endPos; or endPos=0; plasma_node 343 — 7y
0
My bad I realize endPos is a Cframe or vector3, so declare `local endPos; ` instead plasma_node 343 — 7y
0
The variables from line 5 to line 8 get their values from other parts of the script. I'm sure that everything is running, the Interpolate() function is the only thing not working. ChipioIndustries 454 — 7y
Ad

Answer this question