"Changed is not a valid member of Vector3"

Alright so I am trying to make a script that knows when the player is moving and what speed they’re moving with.

Below is the script that would do that, but it outputs "“Changed is not a valid member of Vector3"”.
Now I kind of understand why the error happens, however I have no idea what to do about it.

local char = script.Parent
local vel = char:WaitForChild("HumanoidRootPart").AssemblyLinearVelocity

vel.Changed:Connect(function(vel)
	print(vel.X)
end)

3 Likes

You could connect a Changed event to the HumanoidRootPart and then from there proceed to check the AssemblyLinearVelocity.

what do you mean by this?
char.HumanoidRootPart.Changed doesn’t trigger when you move if that is what you meant (assuming it’s not)

1 Like

Consider this instead:

local char = script.Parent

char:GetPropertyChangedSignal("AssemblyLinearVelocity"):Connect(function(vel)
	print(char.AssemblyLinearVelocity.X)
end)

Achieves what you want it to!

3 Likes

Well why not? .Changed fires everytime a property changes, including assemblyvelocity

1 Like

There’s quite a number of possible solutions here, but the one close to your original code would be by using the GetPropertyChangedSignal:

rootPart:GetPropertyChangedSignal("AssemblyLinearVelocity"):Connect(function()
    ...
end)
1 Like

it gives this error “AssemblyLinearVelocity is not a valid property name”

1 Like

I think I forgot to set it to the humanoidrootpart. Try this instead

local char = script.Parent

char.HumanoidRootPart:GetPropertyChangedSignal("AssemblyLinearVelocity"):Connect(function(vel)
	print(char.HumanoidRootPart.AssemblyLinearVelocity.X)
end)
2 Likes

it doesn’t give an error now, but it doesn’t print either

it is a custom character btw. The humanoidrootpart is inside the torso (I can see in studio the property doesn’t change).

1 Like

Odd.
If you check the HumanoidRootPart in explorer while moving about, it definitely shows the AssemblyLinearVelocity as changing right?

1 Like

nope. It seems like the CFrames and Vector3’s of all the character’s parts are all stuck since spawning (including the velocity property of course).

1 Like

That’s quite bizarre. It may be due to the custom character. Does the server see the character moving about? (and does the client see it moving about?). If it is shown as moving about it should definitely be updating the properties

1 Like

both the client and server show the same movement, and both are stuck… I followed a turtorial on rigging and the joints should be correct (humanoidrootpart → torso)

ok it actually does change the properties on the server when I move the character with my mouse.
So it registrers the player’s visual position from the client, but not the property.

You are clicking on the attachment, not the actual HumanoidRootPart. If you click the HumanoidRootPart, does it show it changing?

The character properties do move on client on my main pc. Maybe the other one had network issues or soemthing. Either way the issue must still be this. It just doesn’t trigger at all. Are you sure that humanoidrootpart:GetPropertySignal is a real thing?

Says that only RunService is used for variables changed by physics. I honestly didn’t know RunService allowed for other things to happen in a script. That makes it a lot easier… hopefully.
Thanks for your time anyway.

Then check with .Heartbeat or .RenderStepped manually instead of relying on events (since they wont fire). Also they probably mean :GetPropertyChangedSignal() that detects certain properties changing.

local hrp = char:WaitForChild('HumanoidRootPart')
local oldVelocity = hrp.AssemblyLinearVelocity

game:GetService('RunService').Heartbeat:Connect(function()
  local velocity = hrp.AssemblyLinearVelocity
  if oldVelocity ~= velocity then
    -- changed
    oldVelocity = velocity
  end
end)
1 Like

yes I did misspell it in my post

my current event

RunService.Stepped:Connect(function()
	if char.HumanoidRootPart.AssemblyLinearVelocity.Magnitude < ? then
		if walkAnimTrack.IsPlaying then
			walkAnimTrack:Stop()
		end
	end
end)

works, even though this gives another issue related to my UIS script. But that is unrelated to this post I guess. Should be able to figure it out.

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