Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

main Menu Camera sometimes shows the player?

Asked by 3 years ago

i have a main menu with a camera that shows a group of people for with a GUI that says "play". but for some reason its works occasionally. and most of the time it camera is set to the player with the GUI still there making it useless. the GUI works perfectly. but with that error, it's useless

my script

local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer

repeat wait() until Player.Character

Camera.CameraType = "Scriptable"
Camera.CFrame = game.Workspace.CAM2.CFrame

script.Parent.Enabled = true
script.Parent.Background1.Visible = true
script.Parent.Strike:Play()
script.Parent.Parent.HealthGui.Enabled = false

can someone tell me whats wrong?

0
Haiiiii! On line four, you have an oopsie -.- See here for more information https://devforum.roblox.com/t/avoiding-wait-and-why/244015 User#30567 0 — 3y
0
Just to let you know, there's a simple fix. Replace line four with "Player.CharacterAdded:Wait()" User#30567 0 — 3y
0
thank you jeremiahbabers 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Try this:

local Camera = workspace.CurrentCamera

Camera.CameraType = "Scriptable"
Camera.CFrame = workspace.CAM2.CFrame

script.Parent.Enabled = true
script.Parent.Background1.Visible = true
script.Parent.Strike:Play()
script.Parent.Parent.HealthGui.Enabled = false

It doesn't wait for the character, it just sets it immediately to the play screen

Ad

Answer this question