#Yo
1 messages · Page 1 of 1 (latest)
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)
I fixed the error but now I have another one
How can I make the gun wobble less? And so that it doesn't move so much when aiming?
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
My savior just redid everything I'll go back and test the code
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
Thanks I'll take that into account
** You are now Level 3! **
Just a moment, I'm redoing the joints.
alr
just watch...
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
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.
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
okay wait me i try
k
is good but aiming the sigh are moving in circle
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)
cant aim
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
returned to the beginning, the gun continues moving when aiming and now it moves more
I haven't read any scripts, it seems like it's moving with the character from a quick guess
uh
yet again I haven't read anything and this might not even be helpful