Currently I have been working on a script which locks first person when the space key is being pressed. It will lock first person and set CameraType into Custom, or otherwise, the CameraType will be Scriptable and it’s CFrame will be a part in Workspace. In this entire process, the character must be sitting. c.IsSeated
is a custom value stored in character to check whether the humanoid is sitting or not by using another script.
local plrs = game:GetService("Players")
local UIP = game:GetService("UserInputService")
local p = plrs.LocalPlayer
local c = p.CharacterAdded:Wait()
local cam = workspace.CurrentCamera
UIP.InputBegan:Connect(function(input, gameProcessed)
if c.IsSeated.Value == true then
if input.KeyCode == Enum.KeyCode.Space then
if p.CameraMode == Enum.CameraMode.Classic then
p.CameraMode = Enum.CameraMode.LockFirstPerson
cam.CameraType = Enum.CameraType.Custom
else
if p.CameraMode == Enum.CameraMode.LockFirstPerson then
p.CameraMode = Enum.CameraMode.Classic
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = c.Humanoid.SeatPart.Parent.Cam.CFrame
end
end
end
end
end)
I also modified LocalTransparencyModifier
on Character’s arms and hands, such that they will be visible in First person. If I do not modified them, the entire character will be transparent when I toggle first person/third person.
runser.RenderStepped:Connect(function()
c:WaitForChild("LeftLowerArm").LocalTransparencyModifier = 0
c:WaitForChild("LeftUpperArm").LocalTransparencyModifier = 0
c:WaitForChild("LeftHand").LocalTransparencyModifier = 0
c:WaitForChild("RightLowerArm").LocalTransparencyModifier = 0
c:WaitForChild("RightUpperArm").LocalTransparencyModifier = 0
c:WaitForChild("RightHand").LocalTransparencyModifier = 0
end)
However, the result:
I don’t know is this a Roblox bug or not, if I set all character’s MeshParts/Parts/Accessories’LocalTransparencyModifier
to 0, this will probably get fixed. However I only want arms and hands’ LocalTransparencyModifier
to 0 but not others.
Any solutions to this problem? Thanks!