i am trying to make a script that finds number values named "Damage" but when roblox looks in the wrong folder it says attempt to call a nil value and stops the rest of the script
note: I am only going to show a certain part of the script
button.MouseButton1Click:Connect(function(button_1_clicked) answer_box.Position = UDim2.new(0, 0, 0, 0) answer_box.Transparency = 0 --find damage value local objects = game.Workspace:GetChildren() for i, child in ipairs(objects) do local childs_children = child:GetChildren() local config = childs_children:FindFirstChildOfClass("Configuration") local damage_value = config:FindFirstChild("Damage") if damage_value then local found_value = instance.new("ObjectValue") found_value.Name = "damage_found" found_value.Parent = button found_value.Value = damage_value end end end)
I think the issue is that damage_value isn't a true or a false and a if statement requires a true or false like this "if true then" or "if false then" or sum like "local nottrue = false if nottrue then" and damage_value isn't any of those so it gives u the nil value. Now some way to fix this is check what the damage value is maybe like
local damage_value = config:FindFirstChild("Damage") if damage_value == nil then print("Damage value was not found") end
but the main point is that damage_value is not true or false so it wont work with a if statement