the actual tool doesn’t follow the viewmodel.
how can i get a fix for this?
this is the localscript that is inside the tool
local Tool = script.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HRP = Character:WaitForChild("HumanoidRootPart")
local Camera = workspace.CurrentCamera
local UIS = game:GetService("UserInputService")
local RS = game:GetService("RunService")
local GuiService = game:GetService("GuiService")
local TS = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SpringModule = require(ReplicatedStorage:WaitForChild("SpringModule"))
local ViewModel
local Gunmodel
local Animations = {}
local MouseSway = SpringModule.new(Vector3.new())
local MovementSway = SpringModule.new(Vector3.new())
local Aiming = false
MouseSway.Speed = 20
MouseSway.Damper = .5
MovementSway.Speed = 20
MovementSway.Damper = .4
local function GetBobbing(Addition, Speed, Modifier)
return math.sin(time() * Addition + Speed) * Modifier
end
Tool.Equipped:Connect(function()
ViewModel = ReplicatedStorage:WaitForChild("ViewModel"):Clone()
ViewModel.Parent = Camera
Gunmodel = ReplicatedStorage.ViewModel:WaitForChild("Cart"):Clone()
Gunmodel.Parent = ViewModel
local Joint = Instance.new("Motor6D")
Joint.Part0 = ViewModel:WaitForChild("Head")
Joint.Part1 = Gunmodel
Joint.C1 = CFrame.new(0, .2, .2)
Joint.Parent = ViewModel:WaitForChild("Head")
Animations["Cartao"] = ViewModel.AnimationController.Animator:LoadAnimation(ReplicatedStorage:WaitForChild("Cartao"))
Animations.Cartao:Play()
RS:BindToRenderStep("Viewmodel", 301, function(DT)
local MouseDelta = UIS:GetMouseDelta()
MouseSway.Velocity += (Vector3.new(MouseDelta.X / 450, MouseDelta.Y / 450))
local MovementSwayAmount = Vector3.new(GetBobbing(10, 1, .2), GetBobbing(5, 1, .2), GetBobbing(5, 1, .2))
MovementSway.Velocity += ((MovementSwayAmount / 25) * DT * 60 * HRP.AssemblyLinearVelocity.Magnitude)
ViewModel:PivotTo(
Camera.CFrame
* CFrame.new(MovementSway.Position.X / 2, MovementSway.Position.Y / 2, 0)
* CFrame.Angles(0, -MouseSway.Position.X, MouseSway.Position.Y)
* CFrame.Angles(0, MovementSway.Position.Y, MovementSway.Position.X)
)
end)
end)
Tool.Unequipped:Connect(function()
if ViewModel then
ViewModel:Destroy()
end
RS:UnbindFromRenderStep("Viewmodel")
end)