Well my main objective is when you press a button the camera goes back to the players.
I did this script and looks that doesn’t work, can someone help me? If it’s possible could the script remain there?
Sript:
wait(13)
local cam = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local cam1 = game.Workspace.cam1
local cam2 = game.Workspace.cam2
local btn = game.StarterGui.ScreenGui.TextButton
cam.CameraType = "Scriptable"
cam:Interpolate(cam2.CFrame, cam1.CFrame, 2)
while true do
wait(3)
cam:Interpolate(cam1.CFrame, cam2.CFrame, 2)
wait(3)
end
btn.MouseButton1Click:Connect(function()
cam.CameraType = "Custom"
cam:Interpolate(cam2.CFrame, cam.CFrame, 2)
end)
The thing is I want to make sure the script remains here as if no the cameras won’t work.
I tried modifying your code to be the same as yours and use the “modern” roblox functions.
(Note also dont use "Cam:Interpolate() since that function is deprecated ( "
local Plr = game.Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local PlrGui = Plr.PlayerGui
local Button = PlrGui:WaitForChild("ScreenGui"):WaitForChild("TextButton")
local Cam = game.Workspace.CurrentCamera
local Cam1 = game.Workspace:WaitForChild("Cam1")
local Cam2 = game.Workspace:WaitForChild("Cam2")
local PlayingTween = nil
local ShouldStop = false
task.wait(5)
local function SetType(Type)
repeat task.wait() Cam.CameraType = Type until Cam.CameraType == Type
end
SetType(Enum.CameraType.Scriptable)
-- // Change the "TweenInfo" info to your preferences
local function MoveTo(CF)
local Tween = game.TweenService:Create(Cam,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out), {
CFrame = CF
})
PlayingTween = Tween
return Tween
end
task.spawn(function()
while not ShouldStop do
task.wait(3)
local Tween1 = MoveTo(Cam1.CFrame)
local Tween2 = MoveTo(Cam2.CFrame)
Tween1:Play()
Tween1.Completed:Wait()
Tween1:Destroy()
Tween2:Play()
Tween2.Completed:Wait()
Tween2:Destroy()
task.wait(3)
end
end)
Button.MouseButton1Click:Connect(function()
ShouldStop = true
if PlayingTween ~= nil and PlayingTween.PlaybackState == Enum.PlaybackState.Playing then
PlayingTween:Cancel()
PlayingTween:Destroy()
end
MoveTo(Char.Head.CFrame)
SetType(Enum.CameraType.Custom)
end)
You can read more about how the Tween Service works here if you have any other questions TweenService
Oh yes works perfectly thak you so much by the way the last question if I want to add more cameras I just need to add like
local Cam3 = game.Workspace:WaitForChild(“cam3”)
or how, but that you so much for all