Hello! I am relatively new to scripting and I need help on something.
Side Note: I have made 1 other post on something similar to this, so sorry if it seems like I am repeating posts. I also feel a bit guilty for making so many scripting support posts, but I am kind of new to scripting so I need a lot of help.
What I Want to Achive
I want to make a camera menu. This would be for viewing different areas of a theater. So for instance, clicking a right arrow UI and it changes the camera. You would be easily able to exit the camera mode.
What I Have so Far
local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
repeat wait() until Player.Character or Player.CharacterAdded:Wait()
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = game.Workspace.CamPart.CFrame
end)
The CameraType should be an Enumerator; Enum.CameraType.Scriptable
Also the Player.Character should be repeat wait() until Player.Character or Player.CharacterAdded:Wait().
Just in case the Character hasnât loaded in yet it will wait until it has.
I am slightly confused on why you would put Enum before CameraType.Scriptable, because you would be setting the camera to Scriptable so, CameraType = Scriptable is right. (i think)
no it should be repeat wait() until Player.Character or Player.CharacterAdded:Wait(), because it will loop until it meets the certain condition, in this case the âconditionâ is Player.Character or Player.CharacterAdded:Wait() Again, Iâm so sorry for not explaining. Iâm horrible at it.
The second to last âend)â at the bottom will break the script since thereâs no reason for another end) in the script. xd I wish I could reword stuff better but it just wonât work e.e
As a side note i donât think you need to wrap the Player.Character or Player.CharacterAdded:Wait() in a loop, because the point of Player.CharacterAdded:Wait() is to wait until the character has loaded and it essentially yields the script in the same way repeat until does. So iâm pretty sure just using this:
Player.Character or Player.CharacterAdded:Wait()
works just fine on itâs own, btw the way you would need to add an if statement
Or wonât work because there is no if statement or anything to check if one condition OR another is true/false equal to another value, etc. It should be either Player.CharacterAdded:Wait() or if Player.Character or Player.CharaterAdded:Wait() then
Is this in a server script or local script? Because if itâs in a serverscript it wonât work.
Also is this in a text button? Iâve made scripts in text labels before thinking it was a text button lmao.
O wait I just noticed, Camera.CFrame needs to be set equal to another CFrame value.