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

How does declaring a variable create a bug?

This breaks and outputs Unable to cast value to Object Script 'ServerScriptService.ModuleScript', Line 31 - upvalue BULLET_create Script 'ServerScriptService.ModuleScript', Line 142 - field shoot

local ignoreAll = {game.Workspace:FindFirstChild("Debris")}
local ignore = {PLAYER.Character, ignoreAll}
local part, position, normal = workspace:FindPartOnRayWithIgnoreList(ray, ignore, false, true)


This works

local ignore = {PLAYER.Character, game.Workspace:FindFirstChild("Debris")}
local part, position, normal = workspace:FindPartOnRayWithIgnoreList(ray, ignore, false, true)

What's the difference and what does it mean by upvalue?

1 answer

✓ Accepted answer

ignoreAll in your first script is a variable that stores an array containing the Debris object, not the Debris object itself, since you used curly braces ("{}"). If you remove the curly braces in the first line, it shouldn't cause an error.

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