Does this script create delays?

local player = game.Players.LocalPlayer
local char = player.Character
local RunService = game:GetService("RunService")

char.Humanoid.CameraOffset = Vector3.new(0, 0, -1)

for i, v in pairs(char:GetChildren()) do
    if v:IsA("BasePart") and v.Name ~= "Head" then

        v:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
            v.LocalTransparencyModifier = v.Transparency
        end)

        v.LocalTransparencyModifier = v.Transparency

    end
end

RunService.RenderStepped:Connect(function(step)
    local ray = Ray.new(char.Head.Position, ((char.Head.CFrame + char.Head.CFrame.LookVector * 2) - char.Head.Position).Position.Unit)
    local ignoreList = char:GetChildren()

    local hit, pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)

    if hit then
        char.Humanoid.CameraOffset = Vector3.new(0, 0, -(char.Head.Position - pos).magnitude)
    else
        char.Humanoid.CameraOffset = Vector3.new(0, 0, -1)
    end
end)

Cursor script:local player = game.Players.LocalPlayer
local char = player.Character
local RunService = game:GetService("RunService")

char.Humanoid.CameraOffset = Vector3.new(0, 0, -1)

for i, v in pairs(char:GetChildren()) do
    if v:IsA("BasePart") and v.Name ~= "Head" then

        v:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
            v.LocalTransparencyModifier = v.Transparency
        end)

        v.LocalTransparencyModifier = v.Transparency

    end
end

RunService.RenderStepped:Connect(function(step)
    local ray = Ray.new(char.Head.Position, ((char.Head.CFrame + char.Head.CFrame.LookVector * 2) - char.Head.Position).Position.Unit)
    local ignoreList = char:GetChildren()

    local hit, pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)

    if hit then
        char.Humanoid.CameraOffset = Vector3.new(0, 0, -(char.Head.Position - pos).magnitude)
    else
        char.Humanoid.CameraOffset = Vector3.new(0, 0, -1)
    end
end)

it is for the body to be seen in first person

1 Like

What do you mean by “delay” could you define what you are exactly looking for?

Assuming you mean lag then the performance hit is negligible unless you are updating LocalTransparencyModifier a lot for it to fire that many times.

The script itself does not create any apparent delays. Though there may be slight delays due to the nature of the operations being performed, such as raycasting and updating the transparency of parts. These delays should be negligible and should not noticeably impact performance. Have you experienced delays, or are you just asking if this script is likely to create any?