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()
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!