#viewmodel

17 messages · Page 1 of 1 (latest)

hidden obsidian
#

hey so im trying to make a viewmodel for an fps game and i came across a problem. now first everything worked perfectly when i tried to parent the viewmodel to the camera and it following it. so i tried to add an animation and when i did nothing happened, so i tried to add a print statement and the script printed that the animation was playing even though on my visual it wasnt.

script:

local camera = workspace.CurrentCamera
local viewmodel = game.ReplicatedStorage:FindFirstChild("ViewModel")
local animationId = "rbxassetid://96784505884831"

if not viewmodel then return end

viewmodel = viewmodel:Clone()
viewmodel.Parent = camera

local arms = viewmodel:FindFirstChild("Arms")
if arms then
    viewmodel.PrimaryPart = arms
else
    return
end

viewmodel.PrimaryPart.Anchored = true
viewmodel:SetPrimaryPartCFrame(camera.CFrame * CFrame.new(0, -1, -2.5))

game:GetService("RunService").RenderStepped:Connect(function()
    if viewmodel and viewmodel.PrimaryPart then
        viewmodel:SetPrimaryPartCFrame(camera.CFrame * CFrame.new(0, -1, -2.5))
    end
end)

local head = player.Character and player.Character:FindFirstChild("Head")
if head then
    head.Transparency = 1
end

local animController = Instance.new("AnimationController")
animController.Parent = viewmodel

local animator = Instance.new("Animator")
animator.Parent = animController

local animation = Instance.new("Animation")
animation.AnimationId = animationId

local loadedAnim = animator:LoadAnimation(animation)
loadedAnim.Looped = true
loadedAnim:Play()```

if anyone could help me i'd really appreciate it. thanks!
red sable
#

I believe this is a problem caused by placing view models into the camera. I didn't see any errors in your code that would cause your animations not to work.
I've done a lot of work on fps projects in roblox and ultimately ended up not putting my view models inside the camera because it caused to many issues that didn't really have an explanation.

Your best bet is to create a folder in workspace and put your view model there. Try that and run your code. My guess is, it will work without any issues.@hidden obsidian

hidden obsidian
hidden obsidian
#

im back with some news

#

good news and bad news

#

good news is that i found out the problem

#

its the model not the script

#

bad news is i cant fix it.

#

no matter what i do the model wont play an animation

#

it says there's no animation inside animation controller even though there is

#

and when i use other scripts

#

it says that there IS an animation

red sable
# hidden obsidian it says that there IS an animation

Are you interested in opening a team create with the affected model and scripts? I can check the rigging of your view model and make sure it's not the problem. I can also look into anything else that might be causing problems.

red sable
#

You could also take a look at this. I ripped it out of a project I was working on years ago, so it's probably missing some dependencies and you most likely won't be able to make it run by just dropping it in your game.

What it does have, is a view model with a decent rig. It was relatively easy to animate. It also contains the module I used to rig the gun to the character and animate it. You might be able to look at it, and learn a little bit from it.

hidden obsidian
#

i was just gonna make the viewmodel for fun and have it as a prototype

#

since i already have a team