i made a script that clones a viewmodel with a gun to the camera when the tool is equipped. But instead, it doesnt clone.
script:
script.Parent.Equipped:Connect(function()
local model = script.Parent.AK47:Clone()
model.Parent = game.Workspace.CurrentCamera
for i,v in pairs (model:GetChildren()) do
if v:IsA("BasePart") then
if v ~= model.PrimaryPart then
local weld = Instance.new("Weld")
weld.Part0 = model.PrimaryPart
weld.Part1 = v
weld.C0 = model.PrimaryPart.CFrame:inverse()
weld.C1 = v.CFrame:inverse()
weld.Name = v.Name
weld.Parent = model.PrimaryPart
end
end
end
game:GetService("RunService").RenderStepped:Connect(function()
model:SetPrimaryPartCFrame(game.Workspace.CurrentCamera.CFrame *CFrame.new(-2,-2,-2))
end)
end)
script.Parent.Unequipped:Connect(function()
game.Workspace.CurrentCamera:FindFirstChild("AK47"):Destroy()
end)
ty sir
