Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local config = require(game:GetService("ReplicatedStorage").SPH_Assets.GameConfig)
- if not config.firstPersonBody then return end
- local Character = script.Parent.Parent
- local RunService = game:GetService("RunService")
- local Humanoid = Character:WaitForChild("Humanoid")
- local Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("UpperTorso")
- local dead, vehicleSeated, gunEquipped = false, false, nil
- Humanoid.Died:Connect(function() dead = true end)
- Humanoid.Seated:Connect(function(seated, seatPart) vehicleSeated = seated and seatPart:IsA("VehicleSeat") end)
- local function CheckForBodyPartNames(model)
- for _, part in ipairs(model:GetChildren()) do
- if part:IsA("BasePart") and not (string.find(part.Name, "Arm") and gunEquipped) then
- return part
- end
- end
- end
- RunService.RenderStepped:Connect(function()
- if not Torso or dead or vehicleSeated or (Character:FindFirstChild("Head") and Character.Head.LocalTransparencyModifier == 0) then
- return
- end
- gunEquipped = Character:FindFirstChildWhichIsA("Tool") and Character:FindFirstChildWhichIsA("Tool"):FindFirstChild("SPH_Weapon")
- local armsEnabled = Torso["Left Shoulder"].Enabled
- for _, obj in ipairs(Character:GetChildren()) do
- if obj:IsA("BasePart") then
- local shouldHide = (string.find(obj.Name, "Arm") and armsEnabled) or
- string.find(obj.Name, "Leg") or
- string.find(obj.Name, "Torso") or
- string.find(obj.Name, "Foot")
- obj.LocalTransparencyModifier = shouldHide and 0 or 1
- elseif obj:IsA("Model") and obj:FindFirstChildWhichIsA("BasePart") then
- local middlePart = obj:FindFirstChild("Middle") or obj:FindFirstChild("Grip") or CheckForBodyPartNames(obj)
- if middlePart and obj.Name ~= "WeaponRig" then
- if string.find(obj.Name, "Holster_") and not config.firstPersonHolsters then
- continue
- end
- middlePart.LocalTransparencyModifier = 0
- end
- elseif obj:IsA("Model") and obj.Name == "Armor" then
- for _, bodyPart in ipairs(obj:GetChildren()) do
- if bodyPart.Name ~= "Head" then
- for _, part in ipairs(bodyPart:GetDescendants()) do
- if part:IsA("BasePart") or part:IsA("Texture") or part:IsA("Decal") then
- part.LocalTransparencyModifier = 0
- end
- end
- end
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement