I’m scripting a loading screen so I want to know why the Interpolate function isn’t working properly like it’s supposed to. This script randomly chooses a point to cframe the camera to, then interpolates to point2 which is the endposition.
I tried adding point parts and placing them in workspace, but for some reason the table I collect from the points folder returns 0 when I use GetChildren().
I also locally did this to see if It would solve the issue and it did, however the positions werent accurate.
Here is my script (I didn’t add any of the variables, because I figured they aren’t necessary);
loader.OnClientEvent:Connect(function()
local interpolation = false
while wait() do
if interpolation == false then
interpolation = true
cam.CameraType = "Scriptable"
local radGroup = radTableGroup[math.random(1,#radTableGroup)]
cam.CameraSubject = radGroup
cam.CFrame = radGroup.CFrame
cam.Focus = radGroup.CFrame + radGroup.CFrame.lookVector * 2
cam:Interpolate(radGroup.point2.CFrame ,radGroup.point2.CFrame + radGroup.CFrame.lookVector * 2,1)
if frame.BackgroundTransparency ~= 1 then
for i = 0,1,.01 do
frame.BackgroundTransparency = i
wait()
end
end
cam.InterpolationFinished:Connect(function()
wait(.5)
for i = 1,0,-.01 do
frame.BackgroundTransparency = i
wait()
end
interpolation = false
end)
end
end
end)
The weird thing about this is that the script doesn’t position the parts correctly though they’re anchored, and cancollide false + positioned the way they’re supposed to.
My previous message I stated the Interpolation works somewhat, the only problem is that it doesn’t interpolate towards the location it’s supposed to if I add the parts in locally.
If the parts already exist through the server, I can’t randomly select them either as if they don’t exist. I tried printing #radTableGroup while it was in workspace and it printed 0.
When I placed the folder with all the points the camera Interpolates to in the script and locally parented into workspace it worked and printed the exact number, but the positions weren’t correct. It didn’t interpolate to the right positions it would interpolate to some random ones.
The only solution I’ve come up with is to set the position and face myself, but I haven’t added 2 sets into 1 table before, so I wouldn’t know how to access the position + the face for the position.
Woops I meant 1 set with 2 things in it. It’s like adding a group to a table, I want to know how to add the group and be able to access the things inside of the group.
local cameraPositions = {
{Pos = Vec3.new(),Focus = Vec3.new()},
{Pos = Vec3.new(),Focus = Vec3.new()},
}
for i = 1,2 do
local info = cameraPositions[i]
local pos = info["Pos"] -- or info.Pos
local focus = info["Focus"] -- or info.Focus
end
This was written on mobile so excuse the shortcuts I wrote. Obviously not tested either. But hopefully you get the point on how you can use tables in this way.