Hi. So like I am working decent with Methods and Object Oriented Programming Stuff.So I made a decent script but the problem is that sometimes, it does not work at all. I want to know why it does not work sometimes and how to fix it.
Here is the code if you wanna look at it. Its pretty bad but like yea.
Local Script
local a = require(UpdateCamera.SetCamera)
local LocalPart = a:new{}
LocalPart.Name = Player.Name .. "_Camera"
LocalPart.Position = Vector3.new()
LocalPart.Transparency = 1
LocalPart.CanCollide = false
LocalPart.Parent = workspace.CurrentCamera
LocalPart:SetLocal()
LocalPart:ChangeCamera(workspace.CurrentCamera:FindFirstChild(Player.Name .. "_Camera"))
Module Script
function Main:new()
setmetatable(Main, self)
self.__index = self
return Main
end
function Main:SetLocal()
local Part = Instance.new("Part")
Part.Color = self.Color
Part.Material = self.Material
Part.Reflectance = self.Reflectance
Part.Transparency = self.Transparency
Part.Name = self.Name
Part.Orientation= self.Orientation
Part.Parent = self.Parent
Part.Position = self.Position
Part.RotVelocity = self.RotVelocity
Part.Velocity = self.Velocity
Part.Anchored = self.Anchored
Part.Archivable = self.Archivable
Part.CanCollide = self.CanCollide
Part.CollisionGroupId = self.CollisionGroupId
Part.Locked = self.Locked
Part.Shape = self.Shape
Part.Size = self.Size
Part.BackSurface = self.BackSurface
Part.BottomSurface = self.BottomSurface
Part.FrontSurface = self.FrontSurface
Part.LeftSurface = self.LeftSurface
Part.RightSurface = self.RightSurface
Part.TopSurface = self.TopSurface
self.Object = Part
end
function Main:ChangeCamera (Part)
repeat wait()
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
until workspace.CurrentCamera.CameraType == Enum.CameraType.Scriptable
workspace.CurrentCamera.CFrame = Part.CFrame
end
