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

Why does my crosshair tween go all wonky?

Asked by
niroqeo 123
3 years ago

Hi

So, I've been scripting this dynamic crosshair, but when I shoot the vertical crosshairs go to the centre of the screen.

(https://youtu.be/-BisrQbaflY)

local crosshairAimTweenInfo = TweenInfo.new(gunStats.crosshairSpeed, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, true, 0)

for i,v in pairs(crosshairFrame:GetChildren()) do
            if v.Name ~= "Center" then
                if string.find(v.Name, "H") then
                    if string.find(v.Name, "L") then
                        local crosshairTween = tweenService:Create(v, crosshairAimTweenInfo, {Position = UDim2.new(0, -50 - 7, v.Position.Y)})
                        crosshairTween:Play()
                    else
                        local crosshairTween = tweenService:Create(v, crosshairAimTweenInfo, {Position = UDim2.new(0, 50, v.Position.Y)})
                        crosshairTween:Play()
                    end
                elseif string.find(v.Name, "V") then
                    if string.find(v.Name, "D") then
                        local crosshairTween = tweenService:Create(v, crosshairAimTweenInfo, {Position = UDim2.new(v.Position.X, 0, 50)})
                        crosshairTween:Play()
                    else
                        local crosshairTween = tweenService:Create(v, crosshairAimTweenInfo, {Position = UDim2.new(v.Position.X, 0, -50 - 7)})
                        crosshairTween:Play()
                    end
                end
            end
        end

-- will run every fire() function

Answer this question