Answered by
5 years ago Edited 5 years ago
Hey!
Your problem here is that you're trying to connect the Changed event to a property rather than an instance. Changed
is actually connected to the instance itself and the connected function will be called with the property's key as its parameter. A code example is shown below...
2 | if param = = "Health" then |
7 | humanoid.Changed:Connect(Check) |
Alternatively, you can use the GetPropertyChangedSignal
method where you can connect changed signals to certain properties. It works exactly like the Changed
event, although it will only be fired when the specified property changes, eliminating the need for an if statement to make sure the changed property is the one you want. A code example for that is also shown below...
2 | local event = humanoid:GetPropertyChangedSignal( "Health" ) |
4 | event:Connect ( function () |
Apart from that, I also see that you're trying to invoke IsA
on Children, which is a table value. :GetChildren()
returns a table with all children of said instance. You'll have to iterate through Children with a for loop or find a singular instance by its index. (e.g. Children[1])
If you have any other questions, feel free to ask.
If this helped, please remember to accept the answer. :)