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

how do i make this POv script happen normal without you needing to press a button to activeate it?

In the script listed below, its a script that when you click a button in a GUI, it becomes POV. how do I make this happen forcefully, like if you were to enter the game you would simply go POV instantly.

wait(1)
local Stepped = game:GetService("RunService").RenderStepped
cam = workspace.CurrentCamera
pal = game.Players.LocalPlayer.Character
deb = false
script.Parent.MouseButton1Click:connect(function()
	deb = not deb
	if deb == true then
		cam.CameraType = "Scriptable"
		script.Parent.Style = "RobloxRoundDefaultButton"
		script.Parent.TextColor3= Color3.new(1,0,0)
		repeat
			cam.CoordinateFrame = pal.Head.CFrame*CFrame.new(0,0,-0.3)
			Stepped:wait()
		until deb == false
		
		cam.CameraType = "Custom"
		script.Parent.Style = "RobloxRoundButton"
		script.Parent.TextColor3= Color3.new(.5,.5,.5)
	end
end)

pal.Humanoid.Changed:connect(function() if pal.Humanoid.Sit == false then deb = false end end)

1 comment

0

player.CameraMode = Enum.CameraMode.LockFirstPerson

1 answer

The following line in a Local Script can be used to force the player into 1st Person POV

game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson

In relation to your original script, there are many enums which you set with string values, while this may work sometimes, they will eventually break when not indexed properly. This is pertinent to the CameraType and ButtonStyle

connect is considered deprecated, use Connect

Activated is better than MouseButton1Click since Activated works for all devices, not just computers

The repeat line is to allow the humanoid changed function to be able to run (the player character loads before being placed in the workspace)

Revised Script

local Stepped = game:GetService("RunService").RenderStepped
local cam = workspace.CurrentCamera
local player = game.Players.LocalPlayer
player.CameraMode = Enum.CameraMode.LockFirstPerson

repeat wait() until player.Character ~= nil and workspace:FindFirstChild(player.Name) ~= nil

local pal = player.Character
local deb = false

script.Parent.Activated:Connect(function()
	deb = not deb
	if deb == true then
		cam.CameraType = Enum.CameraType.Scriptable
		script.Parent.Style = Enum.ButtonStyle.RobloxRoundDefaultButton
		script.Parent.TextColor3 = Color3.new(1, 0, 0)
		repeat
			cam.CFrame = pal.Head.CFrame*CFrame.new(0, 0, -0.3)
			Stepped:wait()
		until deb == false

		cam.CameraType = Enum.CameraType.Custom
		script.Parent.Style = Enum.ButtonStyle.RobloxRoundButton
		script.Parent.TextColor3 = Color3.new(.5,.5,.5)
	end
end)

pal.Humanoid.Changed:Connect(function()
	if pal.Humanoid.Sit == false then
		deb = false
	end
end)

2 comments

0

the game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson thing just makes you go in first person, not POV.

0

Which POV do you want then? the POV of the player (1st / 3rd) or another part?

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