Hello, recently i came across an error in my script where the returned value from a module script’s function was nil. I did a few checks and saw that before returning the value, the module script prints the variable as false (expected behaviour).
I have tried looking into other topics in the devforum, none of them helped me.
for i,v in pairs(workspace:GetPartsInPart(MainPlacementHandler.Preview.Hitbox), OverlapParam) do
if v.Name == "Hitbox" then
HasHitbox = true
end
end
print(HasHitbox, "From module")
if HasHitbox then --Tried to work my way around it, also did not work.
return true
else
return false
end
end
function MainPlacementHandler.UpdatePosition(Position)
local PositionToPlace = MainPlacementHandler.RaycastFromViewport(Position)
local Angles = MainPlacementHandler.Preview:GetPivot().Rotation
MainPlacementHandler.Preview:PivotTo(CFrame.new(MainPlacementHandler.AdvancedRound(PositionToPlace.X, 1), MainPlacementHandler.AdvancedRound(PositionToPlace.Y, 1), MainPlacementHandler.AdvancedRound(PositionToPlace.Z, 1)) * Angles)
local HasHitbox = false
local OverlapParam = OverlapParams.new()
OverlapParam.FilterType = Enum.RaycastFilterType.Blacklist
OverlapParam.FilterDescendantsInstances = {MainPlacementHandler.Preview}
for i,v in pairs(workspace:GetPartsInPart(MainPlacementHandler.Preview.Hitbox), OverlapParam) do
if v.Name == "Hitbox" then
HasHitbox = true
end
end
print(HasHitbox, "From module")
if HasHitbox then --Tried to work my way around it, did not work.
return true
else
return false
end
end