#Proxxy Prompt to make View Model do an interacting animation

136 messages · Page 1 of 1 (latest)

proud nexus
#

So i've been stuck on this for a while, whenever i have tried to trigger the animation when activating the prox prompt it always says "Cannot load the AnimationClipProvider Service."

I have put my viewmodel into the workspace instead of Rep Storage, didnt work, tried game:GetService('RunService').Stepped:Wait() and task.wait(), also didnt work, i need some help figuring this out lol

below are my scripts for my viewmodel and the Prox Prompt script

Local - ViewModel

local Viewmodel = game.Workspace:WaitForChild("Viewmodel")
local viewModelInstance = Viewmodel:Clone()
local Anim = game.ReplicatedStorage:WaitForChild("Anims")
local MainModule = require(game.ReplicatedStorage.ModuleScript)

-- Parts must be anchored in the workspace so this is my fix, does not affect anything else
viewModelInstance.Parent = game.Workspace
viewModelInstance["Left Arm"].Anchored = false
viewModelInstance["Right Arm"].Anchored = false
viewModelInstance["HumanoidRootPart"].Anchored = false

-- idle animation for my viewmodel, took out the animation temporarily when i was messing with locomotion
local Animation = Anim.Idle
Animation.AnimationId = "rbxassetid://"

-- gets the module script
game:GetService("RunService").RenderStepped:Connect(function(Dt)
    MainModule.update(viewModelInstance, Dt)
end)

-- to trigger the the idle anim
game:GetService("UserInputService").InputBegan:Connect(function(input)
    local Humanoid = viewModelInstance:FindFirstChildOfClass("Humanoid") or viewModelInstance:FindFirstChildOfClass("AnimationController")

    if not Humanoid then
        Humanoid = Instance.new("AnimationController")
        Humanoid.Parent = viewModelInstance
    end

    local Animator = Humanoid:FindFirstChildOfClass("Animator")
    if not Animator then
        Animator = Instance.new("Animator")
        Animator.Parent = Humanoid
    end

    local AnimationTrack = Animator:LoadAnimation(Animation)
    AnimationTrack:Play()
end)
bleak wharfBOT
#

studio** You are now Level 8! **studio

proud nexus
#

Module - ViewModel

local module = {}

-- makes the ViewModel attach to the player camera
function module.update(Viewmodel, dt)
    Viewmodel.HumanoidRootPart.CFrame = game.Workspace.Camera.CFrame
end

return module

Script - Prox Prompt to active the animation

local ProximityPrompt = script.Parent
local Anim = game.ReplicatedStorage.Anims:WaitForChild("Interact")

ProximityPrompt.Triggered:Connect(function(plr) -- gets the player
    local hum = workspace.Viewmodel:Clone()
    game:GetService('RunService').Stepped:Wait()
    task.wait()
    local loadAnim = hum.Humanoid.Animator:LoadAnimation(Anim)
    
    loadAnim:Play() -- plays the animation
end)
jagged trout
proud nexus
#

everything is in the workspace except the scripts causing the viewmodel to work

jagged trout
#

You should not clone the model from "ReplicatedStorage" ?

#

Show me the Worckspace at runtime

proud nexus
#

i read everywhere that if you want to use an event trigger for an animation it needs to be in the workspace

#

when i did it in rep storage it did not work

jagged trout
#

In the video there is an error of line 8, of the variable "hum"

#

Have you done any print to see if you get what you expected?

proud nexus
#

yes

#

one moment lemmie get the origional script back in bc i was adjusting it and i did nothing

jagged trout
#

Let me see the code on the laptop, it's difficult on cell phone

#

The Viewmodel has Humanoid?

proud nexus
#

i removed it bc it broke stuff

#

i tried it bc i was running out of ideas

jagged trout
#

This is what causes the error according to the console

#

from line 8

proud nexus
#

i swear to god if it is im gonna end it

jagged trout
#

it is always good to make prints before you make the code, so you are sure to get what you expect in the variables

proud nexus
#

i might have an idea ima try real quick

#

nvm it had the same output

#

yeah

jagged trout
#

no, wait

proud nexus
#

wait it changed

jagged trout
#

It must be because there are 2 models with the same name.

proud nexus
#

I DID FIX SOMETHING

jagged trout
#

working?

#

👀

proud nexus
#

NEVERMIND ‼️

#

yeah no did nothing

jagged trout
#

uh, at least it doesn't give error?

proud nexus
#

same error

#

it was on a different line but my dumbass didnt realize it was the same line of code

jagged trout
#

what

proud nexus
#

ill try to put it through chat gpt to see if it does anything with it

#

if not then im gonna guess it's an engine problem

jagged trout
#

I have a question, and maybe it's because of this:

bleak wharfBOT
#

studio** You are now Level 5! **studio

jagged trout
#

why clone the viewmodel if you can access it without :Clone()?

#

because when you duplicate you get the property of the duplicate and not the one that is for the character

proud nexus
#

because the viewmodel 1. needs to go to every player, and 2. needs to be client side

#

also chat gpt quite literally did nothing with it

jagged trout
#

and the parent of viewmodel on clone?

proud nexus
#
local ProximityPrompt = script.Parent
local Anim = game.Workspace.Anims:WaitForChild("Interact")
local ContentProvider = game:GetService("ContentProvider")

-- Preload the animation
ContentProvider:PreloadAsync({Anim})

ProximityPrompt.Triggered:Connect(function(plr)
    -- Check if the player has a character
    if not plr.Character then
        warn("Player does not have a character")
        return
    end

    -- Clone the viewmodel and set its parent to the workspace
    local viewmodel = workspace.Viewmodel:Clone()
    viewmodel.Parent = workspace

    -- Wait for the next frame to ensure the clone is properly set up
    game:GetService('RunService').Stepped:Wait()

    -- Ensure the cloned viewmodel has an AnimationController and Animator
    local animController = viewmodel:FindFirstChildOfClass("AnimationController")
    if not animController then
        warn("No AnimationController found in viewmodel clone")
        return
    end

    local animator = animController:FindFirstChildOfClass("Animator")
    if not animator then
        warn("No Animator found in viewmodel clone")
        return
    end

    -- Load and play the animation
    local loadAnim = animator:LoadAnimation(Anim)
    loadAnim:Play()
end)
#

what the fuck is this

#

😭

#

it added shit that just isnt needed

#

like why check if it has an animator or that the player has a character

#

actual undertale code

jagged trout
#

The property named "Animation" is the same class on viewmodel?

proud nexus
#

the animation is what holds the animator

#

and its that or the humanoid

#

but the humanoid adds weird collision and doesnt do anything anyways

#

i am tempted to remove the animation but learning what can fix it could probably help in the future

jagged trout
#

if the game is multiplayer, leaving the viewmodel in the workspace will cause more errors, since there will be more than one viewmodel with the same name.

proud nexus
proud nexus
#

but even then at most itll be 2v2

#

its gonna be a survival-horror fps

jagged trout
#

Isn't it better to have the viewmodel inside the player and thus access it more easily from the character's character?

proud nexus
#

that isnt possible with the way i need to do it

#

yes, it would be much more tidy to jsut use replicated storage and clone it from there

#

BUT

jagged trout
#

and what does not make it possible?

proud nexus
#

animations break

#

thats where the "Cannot load the AnimationClipProvider Service." error is usually from

#

if you try to trigger an animation to something cloned from rep storage it wont work

jagged trout
#

let me analyze the video again

proud nexus
#

it need to be in the workspace

jagged trout
proud nexus
#

yes

#

so i need to make the viewmodel clone's parent the workspace

#

which is why the viewmodel clone in the video is in the workspace

jagged trout
#

see, this is what should give error

proud nexus
#

it isnt though

#

no errors have come from that

jagged trout
#

from the video 2 ViewModel are shown, and it is not known which one to access, if the one of the character's camera or the one that is simply in the workspace.

proud nexus
#

it is

#

it selects the clone one

#

thats why hum = the viewmodel clone

#

that isnt to clone the viewmodel its to signify which model is being used

#

thats also why the cloned viewmodel is attached to the player camera and the original one is still in the world

jagged trout
#

try to rename the viewmodel that is not used for the camera

proud nexus
#

it wont do anything

proud nexus
#

when you use hum

jagged trout
#

😟

proud nexus
#

it doesnt use the already made viewmodel

#

after it is cloned, it used the clone instead

#

that's why i am able to automatically make the clone attach to the camera and make it unanchored

#

here one sec

jagged trout
#

I think I understood, the one that is cloned is the one you showed, and you try to put the animation on it

proud nexus
#

yeah

jagged trout
#

ok, I will analyze everything again

proud nexus
#

but the error applied to it and i dont know why because everything i have seen about the error has not fixed my problem

#

i talked to someone pretty experienced before and they were completely lost as well

jagged trout
#

when running the game the viewmodel is already cloned

proud nexus
#

yeah

#

that script is so it can use the cloned viewmodel

jagged trout
#

and this makes you think that the clone is accessed, but this method is to clone

proud nexus
#

as i said before im not cloning it with that

jagged trout
#

the :Clone() is to clone and not to obtain a cloned object.

proud nexus
#

doing local ____ = something:clone() is to make it so you have a shortcut to that clone

jagged trout
#

and by pressing the button you would be cloning a third party instead of accessing the clone.

jagged trout
#

:Clone() is for clone objects

proud nexus
#

yeah

#

once you use it its clones

#

and using it again accesses the cloned model

#

if it cloned it again it would show up in the workspace

jagged trout
#

let me correct it, wait here

proud nexus
#

but there are only 2

#

the original and the cloned

jagged trout
#

from viewmodelinstance, add another name to it

proud nexus
#

no that isnt messing it up at all because i havent been getting any errors that would signify that

#

the error is with the animation itself

jagged trout
#

and to this change the name you added to it," without the :Clone()"

proud nexus
#

nono because then it would use the normal one

#

not the cloned one

#

i dont mean to be rude but i dont think you really know what you're talking about

#

AnimationClipProvider Service is a service and has nothing to do with the viewmodel

barren agate
#

i havent ran through ur code but i know "cannot load animationclipprovider" was a engine bug a couple months ago it may have come back or something

proud nexus
#

oh really?

#

that was a suspicion honestly

barren agate
#

i havent scripted in a while and never messed with animations much so i cant let u know if its a definite engine bug and not an issue with ur code but i remember this being an issue so i thought id lyk

proud nexus
#

it likely is a bug with the engine

#

because everything i read said it was because it wasn't in the workspace but the error still came up after putting it into the workspace

#

ill probably keep the animation details for when im done with the core features then