Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my dynamic crosshair so laggy?

Asked by 3 years ago

I am currently working on a dynamic crosshair, but it's very laggy. Does anyone know why? Here is a video showing the crosshair: https://youtu.be/laGr12VruKo

Here is part of the script that controls the crosshair (Local, inside tool):

local function ChangeSpread(spreadAmount)   
    if spread ~= maxSpread and not aiming then
        mainFrame:TweenSize(
            UDim2.new(0, spreadAmount*50, 0, spreadAmount*50),
            Enum.EasingDirection.Out,
            Enum.EasingStyle.Linear,
            true
        )
    elseif not aiming then
        mainFrame:TweenSize(
            UDim2.new(0, maxSpread*50, 0, maxSpread*50),
            Enum.EasingDirection.Out,
            Enum.EasingStyle.Linear,
            true
        )
    end
end

mouse.Button1Down:Connect(function()
    if not aiming then
        spread = spread + .5
    else
        spread = spread
    end
end)

game:GetService("RunService").RenderStepped:Connect(function(deltaTime)
    changeSpread(spread)
end)

Any help is greatly appreciated!

Answer this question