#Yo

1 messages · Page 1 of 1 (latest)

hearty mountain
#

I was giving my weapon a swing animation, it worked, but then the weapon would stay where the player stopped, and I can't find the error. Could you help me?

#

RunService.RenderStepped:Connect(function()
local rot = camera.CFrame:ToObjectSpace(lastCameraCF)
local X,Y,Z = rot:ToOrientation()
swayCF = swayCF:Lerp(CFrame.Angles(math.sin(X) * currenSwayAMT, math.sin(Y) * currenSwayAMT, 0), .1)
lastCameraCF = camera.CFrame

local humanoid = character:WaitForChild("Humanoid")
if humanoid then
    local bobOffset = CFrame.new()
    
    if humanoid.MoveDirection.Magnitude > 0 then 
        if humanoid.WalkSpeed == 13 then
            bobOffset = CFrame.new(math.cos(tick() * 4) * .08, -humanoid.CameraOffset.Y/3, -humanoid.CameraOffset.Z/3) * CFrame.Angles(math.cos(tick() * 4) * .05, math.sin(tick() * 8) * .1, 0)

        elseif humanoid.WalkSpeed == 20 then
            bobOffset = CFrame.new(math.cos(tick() * 8) * .1, -humanoid.CameraOffset.Y/3, -humanoid.CameraOffset.Z/3) * CFrame.Angles(math(tick() * 8) * .1, math.sin(tick() * 16) * .2, 0)
        end
        
    else 
        bobOffset = CFrame.new(0, -humanoid.CameraOffset.Y/3, 0)
    end
    
    for i, v in pairs(camera:GetChildren()) do
        if v:IsA("Model") then
            v:SetPrimaryPartCFrame(camera.CFrame * swayCF * aimCF * bobOffset)
        end
    end

    if isAiming and framework.viewmodel ~= nil and framework.module.canAim then 
        local offset = framework.viewmodel.AimPart.CFrame:ToObjectSpace(framework.viewmodel.PrimaryPart.CFrame)
        aimCF = aimCF:Lerp(offset, framework.module.aimSmooth)
        currenSwayAMT = aimSwayAMT
    else
        local offset = CFrame.new()
        aimCF = aimCF:Lerp(offset, framework.module.aimSmooth)
        currenSwayAMT = swayAMT
    end
end

end)

hearty mountain
#

How can I make the gun wobble less? And so that it doesn't move so much when aiming?

glass hawk
#

try this

#

RunService.RenderStepped:Connect(function()
local rot = camera.CFrame:ToObjectSpace(lastCameraCF)
local X,Y,Z = rot:ToOrientation()
swayCF = swayCF:Lerp(CFrame.Angles(math.sin(X) * currenSwayAMT, math.sin(Y) * currenSwayAMT, 0), .1)
lastCameraCF = camera.CFrame

local humanoid = character:WaitForChild("Humanoid")
if humanoid then
    local bobOffset = CFrame.new()

    if humanoid.MoveDirection.Magnitude > 0 then 
        if humanoid.WalkSpeed == 13 then
            bobOffset = CFrame.new(math.cos(tick() * 4) * .08, -humanoid.CameraOffset.Y/3, -humanoid.CameraOffset.Z/3) * CFrame.Angles(math.cos(tick() * 4) * .05, math.sin(tick() * 8) * .1, 0)

        elseif humanoid.WalkSpeed == 20 then
            bobOffset = CFrame.new(math.cos(tick() * 8) * .1, -humanoid.CameraOffset.Y/3, -humanoid.CameraOffset.Z/3) * CFrame.Angles(math.sin(tick() * 8) * .1, math.sin(tick() * 16) * .2, 0)
        end

    else 
        bobOffset = CFrame.new(0, -humanoid.CameraOffset.Y/3, 0)
    end

    for i, v in pairs(camera:GetChildren()) do
        if v:IsA("Model") then
            v:SetPrimaryPartCFrame(camera.CFrame * swayCF * aimCF * bobOffset)
        end
    end

    if isAiming and framework.viewmodel ~= nil and framework.module.canAim then 
        local offset = framework.viewmodel.AimPart.CFrame:ToObjectSpace(framework.viewmodel.PrimaryPart.CFrame)
        aimCF = aimCF:Lerp(offset, framework.module.aimSmooth)
        currenSwayAMT = aimSwayAMT
    else
        local offset = CFrame.new()
        aimCF = aimCF:Lerp(offset, framework.module.aimSmooth)
        currenSwayAMT = swayAMT
    end
end

end)

#

The only change made was in this line: math(tick() * 8) → math.sin(tick() * 8)

#

@hearty mountain

hearty mountain
glass hawk
#

alr tell me if it works

#

if it doesnt ill see what else i can do

#

did it work

#

next time dm me for help also

hearty mountain
glass hawk
#

did it work

#

?

#

@hearty mountain

ruby pondBOT
#

studio** You are now Level 3! **studio

hearty mountain
glass hawk
#

alr

hearty mountain
glass hawk
#

oh i see

#

well what do you want it to do

#

i see a problem but i need to know what you want me to fix

#

also are there any error

#

i dont thnk so

#

is it when you like zoom in into the gun

#

its sopposed to stsy still

#

but its shaky

hearty mountain
# glass hawk but its shaky

That's the problem, the weapon moves too much and doesn't move as it should. It should be a simpler swing only when moving and running a little more abruptly, but it's making circles.

glass hawk
#

ok

#

try RunService.RenderStepped:Connect(function()
local rot = camera.CFrame:ToObjectSpace(lastCameraCF)
local X,Y,Z = rot:ToOrientation()
swayCF = swayCF:Lerp(CFrame.Angles(math.sin(X) * currenSwayAMT, math.sin(Y) * currenSwayAMT, 0), .1)
lastCameraCF = camera.CFrame

local humanoid = character:WaitForChild("Humanoid")
if humanoid then
    local bobOffset = CFrame.new()

    if humanoid.MoveDirection.Magnitude > 0 then 
        if humanoid.WalkSpeed == 13 then
            bobOffset = CFrame.new(math.cos(tick() * 4) * 0.04, math.sin(tick() * 4) * 0.02, 0) * CFrame.Angles(math.sin(tick() * 4) * 0.02, 0, 0)

        elseif humanoid.WalkSpeed == 20 then
            bobOffset = CFrame.new(math.cos(tick() * 6) * 0.06, math.sin(tick() * 6) * 0.03, 0) * CFrame.Angles(math.sin(tick() * 6) * 0.03, 0, 0)
        end

    else 
        bobOffset = CFrame.new(0, 0, 0)
    end

    for i, v in pairs(camera:GetChildren()) do
        if v:IsA("Model") then
            v:SetPrimaryPartCFrame(camera.CFrame * swayCF * aimCF * bobOffset)
        end
    end

    if isAiming and framework.viewmodel ~= nil and framework.module.canAim then 
        local offset = framework.viewmodel.AimPart.CFrame:ToObjectSpace(framework.viewmodel.PrimaryPart.CFrame)
        aimCF = aimCF:Lerp(offset, framework.module.aimSmooth * 0.5)
        currenSwayAMT = aimSwayAMT * 0.3
    else
        local offset = CFrame.new()
        aimCF = aimCF:Lerp(offset, framework.module.aimSmooth)
        currenSwayAMT = swayAMT
    end
end

end)

#

@hearty mountain

hearty mountain
#

okay wait me i try

glass hawk
#

k

hearty mountain
glass hawk
#

RunService.RenderStepped:Connect(function()
local rot = camera.CFrame:ToObjectSpace(lastCameraCF)
local X,Y,Z = rot:ToOrientation()
swayCF = swayCF:Lerp(CFrame.Angles(math.sin(X) * currenSwayAMT, math.sin(Y) * currenSwayAMT, 0), .1)
lastCameraCF = camera.CFrame

local humanoid = character:WaitForChild("Humanoid")
if humanoid then
    local bobOffset = CFrame.new()

    if humanoid.MoveDirection.Magnitude > 0 then 
        if humanoid.WalkSpeed == 13 then
            bobOffset = CFrame.new(math.cos(tick() * 4) * 0.04, math.sin(tick() * 4) * 0.02, 0) * CFrame.Angles(math.sin(tick() * 4) * 0.02, 0, 0)
        elseif humanoid.WalkSpeed == 20 then
            bobOffset = CFrame.new(math.cos(tick() * 6) * 0.06, math.sin(tick() * 6) * 0.03, 0) * CFrame.Angles(math.sin(tick() * 6) * 0.03, 0, 0)
        end
    else 
        bobOffset = CFrame.new(0, 0, 0)
    end

    for i, v in pairs(camera:GetChildren()) do
        if v:IsA("Model") then
            if isAiming then
                v:SetPrimaryPartCFrame(camera.CFrame * CFrame.new(0, 0, 0))
            else
                v:SetPrimaryPartCFrame(camera.CFrame * swayCF * aimCF * bobOffset)
            end
        end
    end

    if isAiming and framework.viewmodel ~= nil and framework.module.canAim then 
        local offset = framework.viewmodel.AimPart.CFrame:ToObjectSpace(framework.viewmodel.PrimaryPart.CFrame)
        aimCF = aimCF:Lerp(offset, framework.module.aimSmooth * 0.5)
        currenSwayAMT = 0.001
    else
        local offset = CFrame.new()
        aimCF = aimCF:Lerp(offset, framework.module.aimSmooth)
        currenSwayAMT = swayAMT
    end
end

end)

hearty mountain
glass hawk
#

RunService.RenderStepped:Connect(function()
local rot = camera.CFrame:ToObjectSpace(lastCameraCF)
local X,Y,Z = rot:ToOrientation()
swayCF = swayCF:Lerp(CFrame.Angles(math.sin(X) * currenSwayAMT, math.sin(Y) * currenSwayAMT, 0), .1)
lastCameraCF = camera.CFrame

local humanoid = character:WaitForChild("Humanoid")
if humanoid then
    local bobOffset = CFrame.new()

    if humanoid.MoveDirection.Magnitude > 0 then 
        if humanoid.WalkSpeed == 13 then
            bobOffset = CFrame.new(math.cos(tick() * 4) * 0.04, math.sin(tick() * 4) * 0.02, 0) * CFrame.Angles(math.sin(tick() * 4) * 0.02, 0, 0)
        elseif humanoid.WalkSpeed == 20 then
            bobOffset = CFrame.new(math.cos(tick() * 6) * 0.06, math.sin(tick() * 6) * 0.03, 0) * CFrame.Angles(math.sin(tick() * 6) * 0.03, 0, 0)
        end
    else 
        bobOffset = CFrame.new(0, 0, 0)
    end

    for i, v in pairs(camera:GetChildren()) do
        if v:IsA("Model") then
            v:SetPrimaryPartCFrame(camera.CFrame * swayCF * aimCF * bobOffset)
        end
    end

    if isAiming and framework.viewmodel ~= nil and framework.module.canAim then 
        local offset = framework.viewmodel.AimPart.CFrame:ToObjectSpace(framework.viewmodel.PrimaryPart.CFrame)
        aimCF = aimCF:Lerp(offset, framework.module.aimSmooth)
        currenSwayAMT = 0.01
    else
        local offset = CFrame.new()
        aimCF = aimCF:Lerp(offset, framework.module.aimSmooth)
        currenSwayAMT = swayAMT
    end
end

end)

#

this might fix it or make it worse idk

#

@hearty mountain

#

@Ly

hearty mountain
#

returned to the beginning, the gun continues moving when aiming and now it moves more

hollow oak
#

uh

#

yet again I haven't read anything and this might not even be helpful