Hello everyone! I have, with help, managed to create this script.
local Camera = game.Workspace.CurrentCamera
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(Player)
print("1")
Camera.CameraType = Enum.CameraType.Attach
workspace.CurrentCamera.CameraSubject = workspace.Model.Part
print("2")
wait(5)
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local function resetCameraSubject()
if workspace.CurrentCamera and localPlayer.Character then
local humanoid = localPlayer.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
workspace.CurrentCamera.CameraSubject = humanoid
end
end
end
end)
What it does is focus the camera on a part.
What I want the bottom of the script to do, the part under wait(5), is reset the camera to the default camera. Following the player. How do I make it work? (It does not work at the moment)
And how do I get the player? The script is run inside of starterplayerscripts, but to lock the camera to the head of the player I need to have the player’s name first… I think…
My goal is to be able to click a part. (Works), which makes the camera focus on it (Works). Then for a button to pop up which you can click (works) and when you click on it to exit the focus mode on the part (doesn’t work yet).
The clicking of the button triggers remoteevent2.
The exit system works, but I need to connect that to remoteevent2 so it only happens when I click the button.
This won’t fix your script since there are other issues but this is how you would correctly wait for an event to fire before continuing on with the execution of the script.