oh, I made a third person and a first-person script myself, this might be of use for you!
EDIT: This script i not very beginner-friendly btw
local uis = game:GetService("UserInputService")
local rs = game:GetService("RunService")
local context = game:GetService("ContextActionService")
local plr = game:GetService("Players").LocalPlayer
local Camera = game:GetService("Workspace").CurrentCamera
local mouse = plr:GetMouse()
local cameraDB = false
local zoomDB = false
local xAngle = 0
local yAngle = 0
local Val = Instance.new("NumberValue", plr)
Val.Name = "CameraPosValue"
Val.Value = 8.5
local cameraPos = Vector3.new(2,0,Val.Value)
local is_tps = true
context:BindAction("CameraMovement", function(_,_,input)
xAngle = xAngle - input.Delta.x*0.4
yAngle = math.clamp(yAngle - input.Delta.y*0.4,-80,80)
end, false, Enum.UserInputType.MouseMovement)
local recursive_transparency_mod
recursive_transparency_mod = function(obj, transparency)
if obj:IsA("BasePart") then
obj.LocalTransparencyModifier = transparency
end
for _, ch in pairs(obj:GetChildren()) do
if ch:IsA("Tool") then
continue
end
recursive_transparency_mod(ch, transparency)
end
end
local function set_char_visibility(char, is_visible)
local new_transparency = is_visible and 0 or 1
recursive_transparency_mod(char, new_transparency)
end
plr.CharacterAdded:Connect(function(char)
wait(0.1)
set_char_visibility(char, is_tps)
Camera.CameraType = Enum.CameraType.Scriptable
end)
rs.RenderStepped:Connect(function()
local c = plr.Character
if not c then
return
end
local rootPart = c:FindFirstChild("HumanoidRootPart")
if rootPart then
local startCFrame = CFrame.new((rootPart.CFrame.p + Vector3.new(0,2,0)))*CFrame.Angles(0, math.rad(xAngle), 0)*CFrame.Angles(math.rad(yAngle), 0, 0)
uis.MouseBehavior = Enum.MouseBehavior.LockCenter
cameraPos = Vector3.new(2, 0, Val.Value)
if is_tps then
local cameraCFrame = startCFrame + startCFrame:VectorToWorldSpace(Vector3.new(cameraPos.X,cameraPos.Y,cameraPos.Z))
local cameraFocus = startCFrame + startCFrame:VectorToWorldSpace(Vector3.new(cameraPos.X,cameraPos.Y,-50000))
Camera.CFrame = CFrame.new(cameraCFrame.p,cameraFocus.p)
else
Camera.CFrame = startCFrame
rootPart.CFrame = CFrame.new(rootPart.CFrame.p) * CFrame.Angles(0,math.rad(xAngle),0)
end
end
end)
local TweenService = game:GetService("TweenService")
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
local Goal = {}
Goal.Value = 2.5
local Info = TweenInfo.new(0.30)
local Tween = TweenService:Create(Val, Info, Goal)
Tween:Play()
end
end)
uis.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
local Goal = {}
Goal.Value = 6.6
local Info = TweenInfo.new(0.30)
local Tween = TweenService:Create(Val, Info, Goal)
Tween:Play()
end
end)
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.V then
is_tps = not is_tps
if plr.Character then
set_char_visibility(plr.Character, is_tps)
end
end
end)
its uhh quite long and complicated but if you wanna change the first-person toggle and such just go to the IserInputService function at the bottom and change the keycode and also has zoom (you can remove it if you want)
1 comment
Local Script is placed in StarterGui