Hello
What is the easiest way to position the camera on a distant part, when playtesting in Studio?
If I am on the server side I can use the F shortcut to do this, but this does not work on the client…
Thanks
Hello
What is the easiest way to position the camera on a distant part, when playtesting in Studio?
If I am on the server side I can use the F shortcut to do this, but this does not work on the client…
Thanks
The F key will take you to the part you have selected. Not sure there is a different way.
Why are you trying to do this on the client?
It does not work when playtesting in Studio on the Client side. It is even disabled in the context menu when right clicking on the part
there are multiple parts created locally so I would like to view their locations
I see. Unfortunately, this feature was not considered useful in the client context, so it was not implemented on the client; you’ll have to implement it yourself as a plug-in. Use UserInputService to detect when the client presses “F”, then follow these steps:
BasePart
.You can implement this feature as an alternating function that returns the player’s camera to their character after pressing “F” again. You can implement that behaviour using some boolean state:
local isViewing = false
local function viewSelected()
isViewing = not isViewing
if isViewing then
-- View
else
-- Return
end
end
Returning the camera to the client’s character is as simple as setting its “CameraSubject” to its original value, which is the client’s current Humanoid
.
…Altogether, you’ll get a script like this:
local UserInputService = game:GetService("UserInputService")
local Selection = game:GetService("Selection")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Camera = workspace.CurrentCamera
local isViewing = false
local function tryReturnCamera()
local character = Player.Character
if not character then
return
end
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
Camera.CameraSubject = humanoid
end
end
local function tryViewSelected()
local selected = Selection:Get()[1]
if not (selected and selected:IsA("BasePart")) then
tryReturnCamera()
return
end
isViewing = not isViewing
if isViewing then
Camera.CameraSubject = selected
else
tryReturnCamera()
end
end
local function onInputBegan(input: InputObject, gameProcessedEvent: boolean)
if gameProcessedEvent then
return
end
if input.KeyCode == Enum.KeyCode.F then
tryViewSelected()
end
end
UserInputService.InputBegan:Connect(onInputBegan)
Store this as a LocalScript
in StarterPlayerScripts
, right-click the LocalScript
, and click “Save as Local Plug-in”.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.