So, I know how to do a first person body system that runs every frame.
But, I want to make it run just when you’re in first person, because my game is a fighting game with first person and third person.
Code:
local Character = script.Parent
local Humanoid = Character:WaitForChild('Humanoid')
local RS = game:GetService('RunService')
RS.RenderStepped:Connect(function(Render)
Humanoid.CameraOffset = Vector3.new(0, 0, -1.5)
for index, RootPart in pairs(Character:GetDescendants()) do
if RootPart:IsA('Part') and RootPart.Name ~= 'Handle' and RootPart.Name ~= 'Head' and RootPart.Name ~= 'HumanoidRootPart' then
RootPart.LocalTransparencyModifier = 0
end
end
end)
Some time ago I already tried to using ‘Render:Disconnect()’ when you’re in first person, but without sucess.
put the names of the items you want to ignore in a table
made the script ignore the item if it’s in the ignoreList table
made a bool which checks if the player is in first person by checking the distance from the camera to their head
Made the local transparency modifier 0 when the player is in first person
Try it out and let me know if it’s still not working.
local Character = script.Parent
local Humanoid = Character:WaitForChild('Humanoid')
local RS = game:GetService('RunService')
local camera = workspace.CurrentCamera
local ignoreList = {"Handle", "Head", "HumanoidRootPart"}
RS.RenderStepped:Connect(function(Render)
local isInFirstPerson = (Character:WaitForChild("Head").Position - camera.CFrame.Position).Magnitude < 1
for index, desc in pairs(Character:GetDescendants()) do
local isItemIgnored = table.find(ignoreList, desc.Name)
local isPart = desc:IsA("BasePart")
if isPart and not isItemIgnored then
print(desc.Name)
desc.LocalTransparencyModifier = 0
end
end
end)
EDIT: I made a typo, should be not isItemIgnored instgead of isItemIgnored in the if statement. I changed that.