Do-end block and camera rotation without Scriptable CameraType?

(-but I put it in the same post so I wouldn’t be spamming)

1. What is the purpose of writing “do” outside of a loop statement?

do
	-- code
end

2. How do you make the camera roll a bit without setting the CameraType as Scriptable and using SetRoll?

To answer question 1
do is used for localizing things. It creates a scope that will clean up everything at the end of it.

Take this code for example:

local a = 5
do
local b = 4
print(b)
end
print(a)
print(b)

Your output will be:

> 4
> 5
> nil

The do statement starts a new scope, you assign a new local variable ‘b’ and print it, which will print ‘4’ the end statement now ends the scope, so even variables local to that scope, meaning ‘b’ is cleaned up. Printing ‘a’ results in ‘5’ since its in the global scope so its always accessible, but printing ‘b’ again will result in ‘nil’ since that variable only exist in the do-end statement.

2 Likes

Makes sense, thank you.

now for that second question

For the second one you can probably set the cameras cframe with renderstepped and doing something like
cam.CFrame = cam.CFrame * CFrame.Angles(roll, 0, 0)

(Not sure if that’s the right axis, I can’t check since I’m on my mobile!)

Woah they deprecated CoordinateFrame? When did they do that?

I know, I was surprised too. I got an error using CoordinateFrame doing something recently and checked the wiki and saw that you can just use CFrame anyway.

1 Like

CoordinateFrame = CFrame

CoordinateFrame was deprecated a while back, I assume it was for API consistency (having instances have the property “CFrame”, then there’s that one “CoordinateFrame” sticking out).

Also thanks, I’ll try that @ZacAttackk.

Off topic (sorry), but can I just say that it’s great to see new users on these forums actually making a contribution and using the forums properly rather than joining the group on Roblox, using it as a badge and never returning to the forums.

I know you’ve been on for a month or something, but it’s still nice to see :slight_smile:

Some of these questions the Scripters forum could help me answer though and it doesn’t feel right to post it on the DevForum, but while I’m here, why not.

Also, thanks for the replies to the thread. I’m trying to apply some camera effects to simulate dizziness (whether its a spinning camera or one that loops many rounds in an infinity sign shape).

1 Like