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

Problem Indexing a BoolValue?

Asked by
Moxeh 84
9 years ago

I get this print for some reason ServerScriptService.Map Changer:6: attempt to index local 'destroy' (a function value)

Why do I get this error? I am using the following code

local destroy = game.ReplicatedStorage.RoundStats.Destroy --BoolValue

destroy.Changed:connect(function(property)
    if destroy.Value == true then
    game.Workspace.ChosenOne:Destroy()

1 answer

Log in to vote
3
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

There's a method called :Destroy().

RoundStats.Destroy is choosing that method instead of your BoolValue. (:Destroy() is a function, which is what the error is telling you)

The solution is to just rename the BoolValue to something else that won't conflict with a method/property name.

While more verbose, ShouldDestroy or something similar communicates what your value means better and avoids this problem!

Ad

Answer this question