Hello Developers, I’ve been having some trouble recently creating a loading screen using Camera.
Here’s the problem:
Whenever the Player spawns in, their camera.Cframe is the CamPart (which should be happening) however, the problem begins when the player Clicks the button (to leave the loading screen) their Camera doesn’t switch back to normal. Here’s the script;
function Loading_Module.Activate()
local cam = workspace.Camera
local camPart = workspace.cam.CamPart
local mouse = Player:GetMouse()
local EntrBtn_ = PlayerGui:WaitForChild("LoadingScreen").BG.ButtonFrame.TextButton
local SizeOneFrame = EntrBtn_.Parent.Parent.SizeFrameOne
local SizeTwoFrame = SizeOneFrame.SizeFrameTwo
local SizeThreeFrame = SizeTwoFrame.SizeFrameThree
repeat
wait()
cam.CameraType = Enum.CameraType.Scriptable
until
cam.CameraType == Enum.CameraType.Scriptable
local maxTilt = 10
game:GetService("RunService").RenderStepped:Connect(function()
cam.CFrame = camPart.CFrame * CFrame.Angles(
math.rad((((mouse.Y - mouse.ViewSizeY / 2) / mouse.ViewSizeY)) * -maxTilt),
math.rad((((mouse.X - mouse.ViewSizeX / 2) / mouse.ViewSizeX)) * -maxTilt),
0
)
end)
EntrBtn_.MouseButton1Click:Connect(function() -- Button to exit
cam.CameraSubject = Player.Character.Humanoid
cam.CameraType = Enum.CameraType.Fixed
cam.CFrame = Player.Character.PrimaryPart.CFrame
end)
end
And yes I have the module required & working in the normal LocalScript. *For whatever reason, this doesn’t work. I’ve tried other ways but couldn’t do it^ (If you know anyways to possibly resolve this, please reply!)
Apologies I got mixed up, ignore my last post, try checking to see if the players character exists before setting the cameras cframe. Where are you spawning the character?
@bluebxrrybot I tried replacing the repeat with just the one line.
Same with @Skoliage, both ways didn’t resolve anything. It would seem like that would of done something but it appears it doesn’t even make a change.