How can I fix this script?

Hey, Im not used to using a Getpropertychanged event, but I tried doing it here so that I can have a part that keeps spinning on its Y axis, but Im getting an error that says that 0, 50, 0 is not a valid property

script.Parent:GetPropertyChangedSignal(script.Parent.AssemblyAngularVelocity):Connect(function(property)
	property = script.Parent.AssemblyAngularVelocity
	if property.Y ~= 50 then
		property = Vector3.new(0, 50, 0)
	end
end)

How do I fix this?

2 Likes

You can not use 'GetPropertyChangedSignal` on physical values like vectors etc… Only numbers,strings,boolean, objectvalue…

You might need a while loop/renderstepped loop. Depending on your needs.

1 Like

But wouldn’t this cause Ping issues?

GetPropertyChangedSignal only accepts strings as an argument not vectors.

-- The code thinks that you are trying to
-- find the property called `Vector3.new(0, 50, 0)`
script.Parent:GetPropertyChangedSignal(script.Parent.AssemblyAngularVelocity)

-- Solution
script.Parent:GetPropertyChangedSignal("AssemblyAngularVelocity")
4 Likes

The people above are right, but here’s just a pointer for referencing script.Parent:

local sp = script.Parent
1 Like

Why make a variable for the parent when I can just use script.Parent?

1 Like

You’ll realize when you have to put in a million "script.Parent"s in a shop system GUI. It can help script organization by a TON.

1 Like

Its best to use that in UI, but I personally don’t see a use in other things unless its a big model.

I tried doing this, but its not doing anything.

function Changed()
	if script.Parent.AssemblyAngularVelocity ~= Vector3.new(0, 50, 0) then
		
		script.Parent.AssemblyAngularVelocity = Vector3.new(0, 50, 0)
		
		else return
	end
end

script.Parent:GetPropertyChangedSignal("AssemblyAngularVelocity"):Connect(Changed)