Parameter is not a valid member of LocalScript

  1. What do you want to achieve?

a function the switches animations

  1. What is the issue?

the function isn’t working

  1. What solutions have you tried so far?

I’ve tried bracktets, quotes, parentheses ect.

I have ,on the Developer Hub, looked for solutions but haven’t found any

local player
local character

local function switchanimID(animlocation,anim,id)
	player = game.Players.LocalPlayer
	character = player.Character or player.CharacterAdded:Wait()
	
	character:FindFirstChild("Animate").animlocation.anim=id
end

I cannot figure out where the function’s problem is.

You are not specific on what you want the Path to find,
Animlocation.Anim=id doesnt exist inside Animate, nor is it specified (Assuming), just specify which animation you want to change

“animlocation” is the string value that the animation object is in and anim is the animation object itself. I’m trying to find the path to the “animationID” property. Here is an image highlighting what I am talking about:
parameter problem

Its Probably better to Path it to Idle and its animations, another thing is that the Variables Player and character are not specified before

Question: Are you trying to change the Players Animation when they enter a certain point?

I’m not specifically pathing it to idle, I’m trying to make a function that can change any animation I set it to like walking or jumping animations. I’m not trying to change the animation when they reach a point, just the animations in the script. Also player and character were specified when I put

player = game.Players.LocalPlayer
character = player.Character or player.CharacterAdded:Wait()

Just copy the script from the Player while testing and edit its animations from there, not really a point in doing that unless changing the animations at a certain point.

You may need to explain

What I want to do is create a function which can alter the animations from a tool and to do that I need to specify where each animation is using the parameters. For example if I wanted to swith the walking animation I would put:

switchanimID(walk,WalkAnim,"rbxassetid://[animation]")
--walk is the value
--WalkAnim is the Animation object
-- and the ID is the animation id

I’d like to be proven wrong by someone who knows more about Lua than I do, but I think what you’re trying to do (dynamically access a class or object’s property using a variable string) is impossible.

Figure out what doing this ‘the hard way’ looks like, and just do that.

1 Like

This is right, you can’t directly access member properties of a class. Methods to do this are provided by interfaces only, i.e. functions, they internally expose the member properties to written changes provided by the function input parameters.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.