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

Problem Indexing a BoolValue?

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

✓ Accepted answer

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!

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