Weapon Holster Sway/Movement

Welp, I really do suck at welds. Also, the weapon is part0 or part1?

The Weapon is a Model

And the local weaponModel is a part. idk y its that way but yeah

Anyways Part 0 is Torso
And Part 1 is Weapon.Handle

Aight try this instead:

local Weapon = script.Parent -- WeaponModel
local WeaponModel = Weapon.Model --WeaponMeshPart
local Char = Weapon.Parent
local Weld = Weapon:WaitForChild("Motor6D")

print(WeaponModel.Position)


local Camera = workspace.CurrentCamera

local weaponSway = Spring.new()
weaponSway.Damper = 0.8 --// Modify (lower value = more springy)
weaponSway.Speed = 8 --// Modify (higher value = spring will reach target in less time

local lastCameraRotation = 0

RunService.Heartbeat:Connect(function(delta)
	local _, yRotation, _ = Camera.CFrame:ToOrientation()

	weaponSway:Impulse((yRotation - lastCameraRotation) * delta * 0.05)

    Weld.C0 *= Weld.C1:Inverse() * CFrame.Angles(0, weaponSway.Position, 0) * Weld.C1
end)

Okay so we are getting somewhere now.

But it seems to be infinitely turning in one direction but at least it’s in place now.

local Weapon = script.Parent -- WeaponModel
local WeaponModel = Weapon.Model --WeaponMeshPart
local Char = Weapon.Parent
local Weld = Weapon:WaitForChild("Motor6D")

print(WeaponModel.Position)


local Camera = workspace.CurrentCamera

local weaponSway = Spring.new()
weaponSway.Damper = 0.8 --// Modify (lower value = more springy)
weaponSway.Speed = 8 --// Modify (higher value = spring will reach target in less time

local lastCameraRotation = 0

RunService.Heartbeat:Connect(function(delta)
	local _, yRotation, _ = Camera.CFrame:ToOrientation()

	weaponSway:Impulse((yRotation - lastCameraRotation) * delta )

    Weld.C0 *= Weld.C1:Inverse() * CFrame.Angles(-weaponSway.Position, 0, 0) * Weld.C1
end)

Yea it’s spinning in the right axis now. but like before it’s spinning infinitely lol

Replace with

local _, lastCameraRotation, _ = Camera.CFrame:ToOrientation()

Also Mb, do this also:

RunService.Heartbeat:Connect(function(delta)
	local _, yRotation, _ = Camera.CFrame:ToOrientation()

	weaponSway:Impulse((yRotation - lastCameraRotation) * delta )

    Weld.C0 *= Weld.C1:Inverse() * CFrame.Angles(-weaponSway.Position, 0, 0) * Weld.C1

    lastCameraRotation = yRotation --/ Forgot this also lol
end)

Yea so not sure what’s going on but there is definitely a bug.

So whever i look down towards my character and walk left or backwards it faces that way and does some jitter.

But that’s an issue with my camera immersion script i think.

Anyways i disabled the script for now and it doesn’t seem to be do anything. Like the weapon is just welded to the back no movements or anything or it’s too small to notice im not sure

Welp, I’ll test it tmr and lyk the results

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.