Okay so, I am trying to make a script where a tool has a model of two arms and a gun inside of it, which it should spawn in and attach to the camera, acting as a Viewmodel. I have made a script where only the arms are included, and that works completely fine. But, when I tried to make the same script for a pistol, it straight up doesn’t work. The pistolViewmodel does not show up inside of the game, as if it doesn’t exist. Below are: a screenshot of the model and the code block for it.
local pistol = script.Parent
local camera = game.Workspace.CurrentCamera
local pistolViewmodel = pistol:WaitForChild("pistolViewmodel")
local equipped = false
local cframeOffset = CFrame.new(0, 0, -5)
pistol.Equipped:Connect(function()
equipped = true
end)
pistol.Unequipped:Connect(function()
equipped = false
end)
game:GetService("RunService").RenderStepped:Connect(function()
if equipped == true then
pistolViewmodel.Head.CFrame = camera.CFrame:ToWorldSpace(cframeOffset)
end
end)