I have this camera for a welcome gui screen. Problem: It resets to it’s original position on respawn. I placed the script in StarterCharacterScripts because it’s the only place it works:
local twns = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local cam = workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = workspace:WaitForChild("CamPart").CFrame
local startPos1 = CFrame.new(612.25, 34.5, -607.25)
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
local target = {CFrame = player.Character:WaitForChild("UpperTorso").CFrame}
local anim1 = twns:Create(cam, tweenInfo, target)
player.PlayerGui.Welcome.TextButton.MouseButton1Click:Connect(function()
player.PlayerGui.Welcome.TextButton:TweenPosition(UDim2.new(0.5, 0, 2, 0))
player.PlayerGui.Welcome.TextLabel:TweenPosition(UDim2.new(0.5, 0, -2, 0))
player.PlayerGui.Shop.TextButton:TweenPosition(UDim2.new(0.1, 0, 0.7, 0))
wait(1)
anim1:Play()
print("Camera moved!")
anim1.Completed:Wait()
cam.CameraType = Enum.CameraType.Follow
for i, v in pairs(player.PlayerGui:GetChildren()) do
if v:IsA("ScreenGui") then
v.Enabled = true
end
end
end)
Please don’t hesitate to give suggestions for this issue. Thanks!
I would imagine you need a player added event instead of character added, that way it plays when you join game but not when you respawn. Try that same suggestion but change it to:
If you want to do it the simple way just add in an “if” statement just outside of the “cam.CFrame = workspace:WaitForChild(“CamPart”).CFrame”. This will help ensure that it won’t play when the script resets.