Im making a view model for a flashlight in my game, but its not really working as planned… The hrp is in the right position, but the rest of the view model is kinda just a few hundred studs away for some reason. I don’t think it’s the joints since I rigged it properly cause the animations still play. This is my first view model so don’t judge the methods is use, but here’s my script
--Its a module called by a client
local RunService = game:GetService("RunService")
local currentViewModel
local isOn = script.Parent.Values.IsOn
local HRP = nil
local humanoid = nil
local idleAnimation = nil
local ViewModel = {}
function ViewModel.SetCurrentViewModel(model)
currentViewModel = model
HRP = model.HumanoidRootPart
humanoid = model.Humanoid
idleAnimation = humanoid.Animator:LoadAnimation(model.Animations.Idle)
end
function ViewModel.FollowCamera(player, camera, mouse)
RunService.RenderStepped:Connect(function()
HRP.Position = player.Character.HumanoidRootPart.Position
game:GetService("TweenService"):Create(HRP, TweenInfo.new(.05, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {CFrame = CFrame.lookAt(HRP.Position, mouse.Hit.Position)}):Play()
isOn.Changed:Connect(function(newValue)
if newValue == true then
idleAnimation:Play()
else
idleAnimation:Stop()
end
end)
end)
end
function ViewModel.CreateViewModel(model, player, camera, mouse)
local newViewModel = model:Clone()
newViewModel.Parent = camera
ViewModel.SetCurrentViewModel(newViewModel)
ViewModel.FollowCamera(player, camera, mouse)
return newViewModel
end
return ViewModel
Here’s some pictures to show you what I mean.
What it should be like
what its like when I tested. The tiny light blue thing on the carpet it the outline of the rest of the view model. It still moves and rotates properly, its just way down there.