Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to disable (and renable after disabling) the player camera?

code is in local script within StarterGui; Filteringenabled is true

local debounce = false
local Player = game.Players.LocalPlayer
local camerabutton = game.Workspace.press4camera
local CAMERAPart = game.Workspace.CAMERAPart
local FOCUSPart = game.Workspace.FOCUSPart
local focusonobject = false

function checkplayer(otherpart)
	local humanoid = otherpart.Parent:FindFirstChild("Humanoid")
	if humanoid then
		return game.Players:GetPlayerFromCharacter(otherpart.Parent)
	end
end

function playercam(otherpart)
	if checkplayer(otherpart) == Player then
		if debounce then
			return
		end
		debounce = true
		if focusonobject then
			-- change camera back to default camera
			wait()
		else
			wait()
			-- camera would be affixed to object and focusing on an object to create isometric 3D perspective independent of player control
			playercam = Player.PlayerScripts:WaitForChild("CameraScript")
			wait()
			cam.CameraType = "Watch"
			cam.CameraSubject = FOCUSPart
			cam.CoordinateFrame = CFrame.new(CAMERAPart.Position)
			focusonobject = true
		end
	end
	debounce = false
end

camerabutton.Touched:connect(playercam)

I'm having trouble with the player camera, I don't want the player to be able to move the camera once when the camera is focusing on an object. I want to make the camera focused on an object once the player steps on the button (player cannot move camera), and once the player steps on the button again, the camera returns to the default camera.

Thanks in advance!

1 answer

✓ Accepted answer

this will stop the player from moving /jumping so they cant touch the button again

Player.PlayerScripts.ControlScript.Disabled = true

as for the camera Scriptable makes it where they cant move it with the right mouse button

game.Workspace.Camera.CameraType = "Scriptable"

4 comments

1

Changing the camera type to scriptable did work (the player can't move camera), now I don't know how to script the camera so that it's focusing on

0

cam.CameraSubject = FOCUSPart that part should have done that

1

/ cam.CameraSubject = FOCUSPart / did work when the camera type was "Watch", but now after it's "Scriptable", it's attached to CAMERAPart and looking forward because of / cam.CoordinateFrame = CFrame.new(CAMERAPart.Position) /

1

for clarity Camera is attached to CAMERAPart, but it's looking forward and not at FOCUSPart, and I don't know how to script it to focus on that object.

This discussion is preserved as it was. New answers, comments, and votes are closed.