I need help with my intro script, anybody help?

So I have this intro script that works 75 percent of the time, and was working fine a few minutes ago, I don’t think this is an effective way tho, as sometimes the camera does not load properly, showing your character. any help? Here is part of the script.

--// Client

local Player = game.Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()

local Camera = game.Workspace.CurrentCamera

game.Lighting.Blur.Size = 15

local ready = false --added

local count = 0 --added

--// GUIs

local PlayButton = script.Parent.PLAY

--// Main

repeat wait()

Camera.CameraType = Enum.CameraType.Scriptable

until Camera.CameraType == Enum.CameraType.Scriptable

Camera.CameraType = Enum.CameraType.Scriptable

repeat wait() until script.Parent.Parent == game.Players.LocalPlayer:WaitForChild("PlayerGui")

repeat wait()

Camera.CFrame = game.workspace.CameraPart.CFrame

until Camera.CFrame == game.workspace.CameraPart.CFrame

Camera.CFrame = game.workspace.CameraPart.CFrame

Could you provide a video/gif of the incident happening? Also, there’s some inefficient coding practices here. You shouldn’t need to use a repeat until statement for each bit as you’re waiting until character is added anyways.

Instead of game.Players, use game:GetService("Players") as well. (Nothing important for this, just good practice.)

EDIT: A photo of the explorer would be helpful to see your UI setup.

1 Like

I think the mistake you made was forgetting to use :WaitForChild(). Waiting for the character to load won’t guarantee that the GUIs or client-sided parts are also loaded. I am pretty sure the worspace start loading first, after that the character and at the last the UIs- not sure if it is 100% true, correct me if I’m mistaken.

At the part where you put local PlayButton = script.Parent.PLAY try using local PlayButton = script.Parent:WaitForChild(“PLAY”)
and at Camera.CFrame = game.workspace.CameraPart.CFrame use Camera.CFrame = game.workspace:WaitForChild(“CameraPart”).CFrame

Hope it will work!

2 Likes

All these repeat wait()'s are probably the reason for the errors.

I’m familiar with Camera Manipulation, and I know sometimes the Camera doesn’t do what you’re telling it to do.

Here is a mini-script / idea you could use to understand how to get it to work:

Camera.CameraType = Enum.CameraType.Scriptable
wait(1)
Camera.CameraSubject = game.Workspace.CameraPart
Camera.CoordinateFrame = CFrame.new(game.Workspace.CameraPart.Position)

There is usually a glitch with this because the script moves to fast, so the combat it, we place a wait() between setting the CameraType and the Subject. And instead of using Camera.CFrame use Camera.CoordinateFrame (not sure of the significance since they’re basically the same thing), but set the CoordinateFrame to the position of CameraPart not the CFrame.

I’m not sure if this will help you, but let me know how it goes.

2 Likes