I want to make a ViewModel with arms, but I’m getting an error on line 31
Error:
Players.Ethanlovir.PlayerGui.clientscript.LocalScript:31: invalid argument #2 (Vector3 expected, got nil) - Client - LocalScript:31
Code:
Main Script
--// Services
local runService = game:GetService('RunService')
local replicatedStorage = game:GetService('ReplicatedStorage')
local players = game:GetService("Players")
--// Objects
local ViewModel = replicatedStorage.main.ViewModel:Clone()
local camera = workspace.CurrentCamera
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild('Humanoid')
--// Modules
local config = require(ViewModel.config)
--// MainCode
local cf = CFrame.new()
ViewModel.Parent = camera
local walkAnimationSpeed = 5
local walkAnimationSize = 4
local animations = {
['Hold'] = ViewModel.AnimationController.Animator:LoadAnimation(ViewModel.Animations.Hold)
}
animations['Hold']:Play()
cf = config.Offset_From_Camera
function positionModel()
ViewModel:SetPrimaryPartCFrame(camera.CFrame*cf)
if humanoid.MoveDirection.Magnitude > 0 then
cf = cf:Lerp(CFrame.new(config.Offset_From_Camera.X+math.sin(time()*walkAnimationSpeed)/walkAnimationSize, config.Offset_From_Camera.Y+math.cos(time()*walkAnimationSpeed)/walkAnimationSize,0),.1)
else
cf = cf:Lerp(config.Offset_From_Camera,0.2)
end
end
runService.RenderStepped:Connect(positionModel)
Module Script
local module = {}
module.OffsetFromCamera = CFrame.new(0,-1.2,1.5)
return module
Any ideas on how to fix?