Intro Camera Script Issue

Hey everyone!

I’m currently working on a Camera Introduction script for my game. When the player joins the game, their camera will move around different parts of my building until they press a play button. The script doesn’t have anything that sets it off, it’s just a localscript under StarterGui.

The issue is simple. When the player resets their character, it’ll re-execute the localscript even if it’s destroyed/disabled. Does anyone have the adequate knowledge to provide a solution for this? Would adding a CharacterAdded/PlayerAdded event help?

If you need the script, let me know, but I don’t think it’s needed as this would happen with any ordinary localscript.

1 Like

Only thing I can really think of, is if the script is in a ScreenGui you could disable the ResetOnSpawn property but that isn’t the case

Try putting it in StarterPlayerScripts instead

I just realised that I don’t have the camera script fully working yet so I can’t see if it restarts on reset or not. The issue is I don’t know how to reset the camera to view the character again, I’ve tried multiple ways but it doesn’t work. The script is below. What could I add in that would reset the player’s camera?

local button = script.Parent

local StarterGui = game:GetService("StarterGui")

local camera = game.Workspace.CurrentCamera

local player = game.Players.LocalPlayer

button.MouseEnter:Connect(function()

button:TweenSize(UDim2.new(0, 167,0, 47),"Out","Quad",0.1,true)

end)

button.MouseLeave:Connect(function()

button:TweenSize(UDim2.new(0, 152,0, 39),"Out","Quad",0.1,true)

end)

script.Parent.MouseButton1Click:Connect(function()

camera.CameraType = "Custom"

camera.CameraSubject = player.Character.Humanoid

camera.CameraType = "Custom"

camera.CFrame = player.Character.Head.CFrame

script.Parent.Visible = false

script.Parent.Parent.Parent.IntroScreen.Frame1.Visible = true

script.Parent.Parent.Parent.IntroScreen.Frame1:TweenSize(UDim2.new(4, 0,4, 0),"Out","Quad",2,true)

wait(0.5)

script.Parent.Parent.Parent.IntroScreen.Frame1.Frame2.Visible = true

wait(0.5)

script.Parent.Parent.Parent.IntroScreen.Frame1.Frame2:TweenSize(UDim2.new(4, 0,4, 0),"Out","Quad",3,true)

wait(0.5)

script.Parent.Parent.Parent.IntroScreen.Frame1.Frame2.Frame3.Visible = true

script.Parent.Parent.Parent.IntroScreen.Frame1.Frame2.Frame3:TweenSize(UDim2.new(4, 0,4, 0),"Out","Quad",3,true)

wait(1)

script.Parent.Parent.Parent.IntroScreen.Welcome.Visible = true

wait(1.5)

script.Parent.Parent.Parent.IntroScreen.Kool.Visible = true

script.Parent.Parent.Parent.IntroScreen.Kafe.Visible = true

wait(0.5)

script.Parent.Parent.Parent.IntroScreen.TextLabel.Visible = true

script.Parent.Parent.Parent.IntroScreen.TextLabel.Text = ("Loading Assets... (1/3)")

wait(1)

script.Parent.Parent.Parent.IntroScreen.TextLabel.Text = ("Loading Assets... (2/3)")

wait(2)

script.Parent.Parent.Parent.IntroScreen.TextLabel.Text = ("Loading Assets... (3/3)")

wait(3)

script.Parent.Parent.Parent.IntroScreen.Frame1:TweenSize(UDim2.new(0.01, 0,0.01, 0),"Out","Quad",2,true)

wait(0.5)

script.Parent.Parent.Parent.IntroScreen.Kafe.Visible = false

script.Parent.Parent.Parent.IntroScreen.Kool.Visible = false

script.Parent.Parent.Parent.IntroScreen.Welcome.Visible = false

script.Parent.Parent.Parent.IntroScreen.TextLabel.Visible = false

wait(0.5)

script.Parent.Parent.Parent.AllGui.Enabled = true

script.Parent.Parent.Parent.Point.Enabled = true

wait(1)

game.StarterGui.IntroGUI:Destroy()

StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)

player.PlayerGui.IntroScreen:Destroy()

end)

Where is the script located? Depending on its location, you shouldn’t need Character/PlayerAdded.

It’s now in StarterPlayerScripts and still functions efficiently thanks to @JackscarIitt, but I’m not sure if it’s fixed the issue which I created this topic for due to the above post! ^

Ah okay, so you want to reset the camera? Is it the function inside of the script.Parent.MouseButton1Click?

If so, you could just do something like this:

-- Declare the function by itself
local function doCameraStuff()
    camera.CameraType = "Custom"
    camera.CameraSubject = player.Character.Humanoid
    camera.CameraType = "Custom"
    camera.CFrame = player.Character.Head.CFrame
    script.Parent.Visible = false
--...

-- Same connection as before, just declared differently.
script.Parent.MouseButton1Click:Connect(doCameraStuff)
-- Call the function again if the character is added
game:GetService('Players').LocalPlayer.CharacterAdded:Connect(doCameraStuff)

Yes, it’s inside a MouseButton1Click! Could you rewrite this incorporated into the script as I’m not sure how to add it in. Sorry! :frowning:

I did. I just added the first few lines of your MouseButton1Click connection into a function, you can just paste the rest.

So, I made another LocalScript under the TextButton. Would this be it?

No, it should be the same script.

local button = script.Parent

local StarterGui = game:GetService("StarterGui")

local camera = game.Workspace.CurrentCamera

local player = game.Players.LocalPlayer

button.MouseEnter:Connect(function()

button:TweenSize(UDim2.new(0, 167,0, 47),"Out","Quad",0.1,true)

end)

button.MouseLeave:Connect(function()

button:TweenSize(UDim2.new(0, 152,0, 39),"Out","Quad",0.1,true)

end)

local function doCameraStuff()

camera.CameraType = "Custom"

camera.CameraSubject = player.Character.Humanoid

camera.CameraType = "Custom"

camera.CFrame = player.Character.Head.CFrame

script.Parent.Visible = false

script.Parent.Parent.Parent.IntroScreen.Frame1.Visible = true

script.Parent.Parent.Parent.IntroScreen.Frame1:TweenSize(UDim2.new(4, 0,4, 0),"Out","Quad",2,true)

wait(0.5)

script.Parent.Parent.Parent.IntroScreen.Frame1.Frame2.Visible = true

wait(0.5)

script.Parent.Parent.Parent.IntroScreen.Frame1.Frame2:TweenSize(UDim2.new(4, 0,4, 0),"Out","Quad",3,true)

wait(0.5)

script.Parent.Parent.Parent.IntroScreen.Frame1.Frame2.Frame3.Visible = true

script.Parent.Parent.Parent.IntroScreen.Frame1.Frame2.Frame3:TweenSize(UDim2.new(4, 0,4, 0),"Out","Quad",3,true)

wait(1)

script.Parent.Parent.Parent.IntroScreen.Welcome.Visible = true

wait(1.5)

script.Parent.Parent.Parent.IntroScreen.Kool.Visible = true

script.Parent.Parent.Parent.IntroScreen.Kafe.Visible = true

wait(0.5)

script.Parent.Parent.Parent.IntroScreen.TextLabel.Visible = true

script.Parent.Parent.Parent.IntroScreen.TextLabel.Text = ("Loading Assets... (1/3)")

wait(1)

script.Parent.Parent.Parent.IntroScreen.TextLabel.Text = ("Loading Assets... (2/3)")

wait(2)

script.Parent.Parent.Parent.IntroScreen.TextLabel.Text = ("Loading Assets... (3/3)")

wait(3)

script.Parent.Parent.Parent.IntroScreen.Frame1:TweenSize(UDim2.new(0.01, 0,0.01, 0),"Out","Quad",2,true)

wait(0.5)

script.Parent.Parent.Parent.IntroScreen.Kafe.Visible = false

script.Parent.Parent.Parent.IntroScreen.Kool.Visible = false

script.Parent.Parent.Parent.IntroScreen.Welcome.Visible = false

script.Parent.Parent.Parent.IntroScreen.TextLabel.Visible = false

wait(0.5)

script.Parent.Parent.Parent.AllGui.Enabled = true

script.Parent.Parent.Parent.Point.Enabled = true

wait(1)

game.StarterGui.IntroGUI:Destroy()

StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)

player.PlayerGui.IntroScreen:Destroy()

end

game:GetService('Players').LocalPlayer.CharacterAdded:Connect(doCameraStuff)
script.Parent.MouseButton1Click:Connect(doCameraStuff)

This is what I needed, thanks! Unfortunately, there is an error. :frowning:

My bad, forgot to remove the parentheses at the end. I made an edit that should work.

Didn’t work. :frowning: No errors for the script specifically, although I’m not sure which one it is out of these:

My bad again, I made an edit to that post. Should work now.

The button works now but the camera doesn’t reset to the player; I don’t see any errors.

Does it work when you press the button or no?

No, it doesn’t reset the camera.

I’m confused as to what you mean by reset the camera. You want it to be type custom and the CameraSubject to be the humanoid?

Yep. I want it to go from viewing a CFrame position somewhere else in the building back to viewing the humanoid of the player.

Well the script I gave you is only going to whatever clicking the button does. That isn’t what you want?