Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

[Closed] Changed property?

Asked by
ImageLabel 1541 Moderation Voter
9 years ago
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


0
Why was this downvoted once? This is a perfectly constructed question... Unclear 1776 — 9y

1 answer

Log in to vote
0
Answered by
Unclear 1776 Moderation Voter
9 years ago

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.

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. ImageLabel 1541 — 9y
Ad

Answer this question