so i try to Run ViewModel animation but for some reason it wont run idk if it because of my script or my ViewModel it doesnt have any error i try remake my code many time and it still wont run
here my Script if you guy wonder if i do anything wrong :
local tool = script.Parent
local Handle = tool.Handle
local player = game.Players.LocalPlayer
local Char = player.Character or player.CharacterAdded:Wait()
local mouse = player:GetMouse()
local VM = nil
local Runservic=game:GetService("RunService")
local Uis=game:GetService("UserInputService")
local Camera = workspace.CurrentCamera
local Head = Char:WaitForChild("Head")
local Connection = nil
local track = nil
local clickConnection = nil
local ANIMATION_ID = "rbxassetid://117944723150421"
local function TranparencyTool(Num)
for _,v in pairs(Handle:GetChildren())do
if v:IsA("BasePart") or v:IsA("MeshPart") then
v.LocalTransparencyModifier = Num
end
end
end
tool.Equipped:Connect(function()
VM = game.ReplicatedStorage:WaitForChild("VM"):WaitForChild("VM.3"):Clone()
local hum = VM:WaitForChild("Humanoid", 5)
local Animator = hum:WaitForChild("Animator", 5)
if Animator then
local animObj = Instance.new("Animation")
animObj.AnimationId = ANIMATION_ID
track = Animator:LoadAnimation(animObj)
end
clickConnection = mouse.Button1Down:Connect(function()
print("click")
if track then
track:Play()
print("play")
else
warn("Animation track is not loaded!")
end
end)
Connection = Runservic.RenderStepped:Connect(function()
local distand = (Head.Position - Camera.CFrame.Position).Magnitude
if distand <= 1.5 then
VM.Parent = Camera
VM:PivotTo(Camera.CFrame)
TranparencyTool(1)
--print("is active")
elseif distand >= 1 then
TranparencyTool(0)
VM:PivotTo(CFrame.new(0,-50,0))
end
end)
end)
tool.Unequipped:Connect(function()
if Connection then
Connection:Disconnect()
Connection = nil
clickConnection:Disconnect()
clickConnection = nil
VM:Destroy()
end
end)

