what i’m trying to achieve is for the camera to be fixed on an invisible part, and when the player presses play, the camera is not stuck on that part anymore, but the players camera goes back to normal.
the camera becomes fixed to the part, but when i press play, nothing happens.
my script:
wait()
print("script is working.")
local btn = game.StarterGui.ScreenGui.TextButton
local cam = game.Workspace.CurrentCamera
local FocusPart = game.Workspace.FocusPart
cam.CameraType = "Scriptable"
cam.Focus = FocusPart.CFrame
wait(1)
btn.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
local human = player:FindFirstChild("Humanoid")
if human then
cam.CameraSubject = human
end
end)
Nevermind I spotted the mistake. The mistake is that you are using the ScreenGui and not the Player’s Gui.
wait()
print("script is working.")
local player = game.Players.LocalPlayer
local btn = player.PlayerGui.ScreenGui.TextButton
local cam = game.Workspace.CurrentCamera
local FocusPart = game.Workspace.FocusPart
cam.CameraType = Enum.CameraType.Scriptable
cam.Focus = FocusPart.CFrame
wait(1)
btn.MouseButton1Click:Connect(function()
local human = player:FindFirstChild("Humanoid")
if human then
cam.CameraSubject = human
end
end)
wait()
print("script is working.")
local player = game.Players.LocalPlayer
local Character = player.Character or player.Character:Wait() --- Get the player's character
local btn = player.PlayerGui.ScreenGui.TextButton
local cam = game.Workspace.CurrentCamera
local FocusPart = game.Workspace.FocusPart
cam.CameraType = Enum.CameraType.Scriptable
cam.Focus = FocusPart.CFrame
wait(1)
btn.MouseButton1Click:Connect(function()
if Character then
cam.CameraSubject = Character
end
end)