Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[Closed] Changed property?

game:FindService('Players').PlayerAdded:connect(function (player)
	player.Changed:connect(function (addedProperty)

		if player[addedProperty] == player.Neutral then
			print('isNeutral', player[addedProperty])
		end

	end)
end)

The code above is basically just a reproduction of the error I'm faced with in my actual lengthy code. I should also mention that the error doesn't really affect the code because changing the Neutral property in this context would print the new value. However, an explanation as to how the error relates to the code would be greatly appreciated :D


Output

20:54:41.538 - Unable to query property AccountAgeReplicate. It is not scriptable 20:54:41.539 - Script 'ServerScriptService.Script', Line 3 20:54:41.540 - Stack End 20:54:41.929 - An error occurred 20:54:41.930 - Script 'ServerScriptService.Script', Line 3 20:54:41.931 - Stack End


1 comment

0

Why was this downvoted once? This is a perfectly constructed question...

1 answer

✓ Accepted answer

I cannot seem to replicate your error, but from inspection I believe you were attempting to access a key that was not supposed to be accessed, so ROBLOX is throwing an error.

However, it is important to note that you did not actually write code that does what you want it to do! Basically, if there is a changed property that is equal to whatever the player's current Neutral property is equal to, it will print. From your post, it seemed like you only wanted to print when the Neutral property was changed. The fixed code is below. Pay close attention to line 3!

game:GetService("Players").PlayerAdded:connect(function(player)
	player.Changed:connect(function(property)
		if property == "Neutral" then
			print("isNeutral", player[property])
		end
	end)
end)

If you do a proper check like above, you should not run into that error again.

1 comment

0

What I was trying to do on line 4 was checking that the value of the new property was equal to the player's corresponding property's value. However, yeah, I guess there I over-complicated it. Thanks.

This discussion is preserved as it was. New answers, comments, and votes are closed.